QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747375 | #9746. 平方根 | nekoyellow | WA | 3ms | 11656kb | C++23 | 673b | 2024-11-14 17:02:02 | 2024-11-14 17:02:02 |
Judging History
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[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) 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: 11564kb
input:
1100110111
output:
4.8284271247
result:
ok found '4.828427125', expected '4.828427125', error '0.000000000'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 11656kb
input:
0
output:
1.4142135624
result:
wrong answer 1st numbers differ - expected: '0.0000000', found: '1.4142136', error = '1.4142136'