|
||||||||||
Monotone SE MinTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 456 Accepted Submission(s): 143 Problem Description 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. Input 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. Output For each case, output the minimum possible squared error in one line, accurate up to 3 decimal places. Sample Input
Sample Output
Author scnu | ||||||||||
|