yukicoder-576
从 Trac 迁移的文章
这是从旧校内 Wiki 迁移的文章,可能存在一些样式问题,您可以向 memset0 反馈。
原文章内容如下:
{{{
#!html
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script>
<script type="text/javascript" async src="http://10.71.10.90/sfiction/tool/MathJax/MathJax-master/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<style>
.input, pre {
display: block;
padding: 9.5px;
margin: 0 0 10px;
font-size: 13px;
line-height: 1.42857143;
color: #333;
word-break: break-all;
word-wrap: break-word;
background-color: #f5f5f5;
border: 1px solid #ccc;
border-radius: 4px;
}
</style>
}}}
== [https://yukicoder.me/problems/no/576 No.576 E869120 and Rings] ==
=== Description ===
{{{
#!html
<p>有个长度为$N$的环形字符串,每个元素要么是$0$要么是$1$。现在你需要找一个长度大于等于$K$的连续子串,使得$1$的个数和长度的比值最大。</p>
}}}
=== Input ===
{{{
#!html
<p class="input">
$N$ $K$<br>
$a_1a_2\dots a_N$
</p>
<p>$1 \le K \le N \le 500000, 0 \le a_i \le 1$</p>
}}}
=== Output ===
{{{
#!html
<p>输出最大比值,误差在$10^{-6}$内就算对。</p>
}}}
=== Sample ===
==== Sample 1 ====
输入
{{{
#!html
<pre>
8 4
11101110
</pre>
}}}
输出
{{{
#!html
<pre>
0.857142857142857
</pre>
}}}
==== Sample 2 ====
输入
{{{
#!html
<pre>
8 4
11011001
</pre>
}}}
输出
{{{
#!html
<pre>
0.833333333333333
</pre>
}}}
==== Sample 3 ====
输入
{{{
#!html
<pre>
10 4
1001001001
</pre>
}}}
输出
{{{
#!html
<pre>
0.6
</pre>
}}}
No.576 E869120 and Rings
Description
有个长度为$N$的环形字符串,每个元素要么是$0$要么是$1$。现在你需要找一个长度大于等于$K$的连续子串,使得$1$的个数和长度的比值最大。
Input
$N$ $K$
$a_1a_2\dots a_N$
$1 \le K \le N \le 500000, 0 \le a_i \le 1$
Output
输出最大比值,误差在$10^{-6}$内就算对。
Sample
Sample 1
输入
8 411101110
输出
0.857142857142857
Sample 2
输入
8 411011001
输出
0.833333333333333
Sample 3
输入
10 41001001001
输出
0.6