QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#747406#9746. 平方根nekoyellowWA 0ms3804kbC++23618b2024-11-14 17:06:422024-11-14 17:06:43

Judging History

This is the latest submission verdict.

  • [2024-11-14 17:06:43]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3804kb
  • [2024-11-14 17:06:42]
  • Submitted

answer

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

double f(int len) {
    if (len & 1) return (len + 1) / 2;
    return len/2 - 1 + sqrt(2);
}

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

    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 += f(n - pre);
            pre = -1;
        }
    }
    if (pre != -1) ans += f(n - pre);
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3804kb

input:

1100110111

output:

10.8284271247

result:

wrong answer 1st numbers differ - expected: '4.8284271', found: '10.8284271', error = '1.2426407'