当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2195:Monotone SE Min

题目描述
Given a sequence of bits (0's and 1's), we want to find an arbitrary monotonically increasing curve (单调递增函数)that best fits the bits. That is, the i-th bit is b(i), and we want to find some curve, f, such that for x<y, f(x) <= f(y), and the sum over i of (f(i)-b(i))^2 (the squared error)(方差) is minimized. Given the sequence of bits as a string, return the minimum possible squared error.
输入解释
Multiple test cases!
For each case the input contains a string consisting of only 0 and 1 in one line. The bits string will contain between 1 and 200 elements.
输出解释
For each case, output the minimum possible squared error in one line, accurate up to 3 decimal places.
输入样例
00
101
输出样例
0.000
0.500

Hint: For example 1, we can make f(1) = 0,   f(2) = 0.
      For example 2, we can make f(1) = 0.5, f(2) = 0.5, f(3) = 1.
来自杭电HDUOJ的附加信息
Author scnu
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2195

最后修改于 2020-10-25T22:51:21+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000/1000MS(Java/Others) 32768/32768K(Java/Others)