QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#747379#9746. 平方根nekoyellowWA 4ms12088kbC++23690b2024-11-14 17:02:442024-11-14 17:02:44

Judging History

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

  • [2024-11-14 17:02:44]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:12088kb
  • [2024-11-14 17:02:44]
  • 提交

answer

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

const int N = 1e6 + 7;
double dp[N];

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    dp[0] = 0; dp[1] = 1; dp[2] = sqrt(2);
    for (int i = 3; i < N; i++) {
        dp[i] = dp[i/2] + dp[(i-1)/2];
    }

    string s;
    cin >> s;
    int n = s.size();

    double ans = 0;
    int pre = -1;
    for (int i = 0; i < n; i++) {
        if (s[i] == '1') {
            if (pre == -1) pre = i;
        } else {
            if (pre != -1) ans += dp[i - pre];
            pre = -1;
        }
    }
    if (pre != -1) ans += dp[n - pre];
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 11680kb

input:

1100110111

output:

4.8284271247

result:

ok found '4.828427125', expected '4.828427125', error '0.000000000'

Test #2:

score: 0
Accepted
time: 2ms
memory: 11596kb

input:

0

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #3:

score: 0
Accepted
time: 2ms
memory: 11812kb

input:

1

output:

1.0000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #4:

score: 0
Accepted
time: 2ms
memory: 11804kb

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #5:

score: -100
Wrong Answer
time: 4ms
memory: 12088kb

input:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

495833.4237922730

result:

wrong answer 1st numbers differ - expected: '500000.4142136', found: '495833.4237923', error = '0.0083340'