QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#745023#9746. 平方根gggheWA 7ms11824kbC++20815b2024-11-14 01:27:312024-11-14 01:27:31

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 01:27:31]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:11824kb
  • [2024-11-14 01:27:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 1'000'010;
double dp[N];

int main() {
    string s;
    cin >> s;

    double ans = 0.0;
    dp[1] = 1.0;
    
    for (int i = 1; i < N; ++i) {
        dp[i] = max(sqrt(i * 1.0), dp[i]);
        if (i * 2 + 1 < N) {
            dp[i * 2 + 1] = max(dp[i * 2 + 1], 2.0 * dp[i]);
        }
        if (i * 2 < N) {
            dp[i * 2] = max(dp[i * 2], dp[i] + dp[i - 1]);
        }
    }

    int n = s.length();
    int i = 0;
    while (i < n) {
        if (s[i] == '0') {
            i++;
            continue;
        }

        int st = i;
        while (i < n && s[i] == '1') {
            i++;
        }
        int len = i - st;
        ans += dp[len];
    }

    printf("%.6f\n", ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 11824kb

input:

1100110111

output:

4.828427

result:

wrong answer 1st numbers differ - expected: '4.8284271', found: '4.8284270', error = '0.0000000'