QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745027 | #9746. 平方根 | ggghe | WA | 28ms | 20136kb | C++20 | 827b | 2024-11-14 01:30:11 | 2024-11-14 01:30:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1'000'010;
long double dp[N];
int main() {
string s;
cin >> s;
long double ans = 0.0;
dp[1] = 1.0;
for (int i = 1; i < N; ++i) {
dp[i] = max(sqrt(i * 1.L), dp[i]);
if (i * 2 + 1 < N) {
dp[i * 2 + 1] = max(dp[i * 2 + 1], 2.L * 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("%.12Lf\n", ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 8ms
memory: 19480kb
input:
1100110111
output:
4.828427124746
result:
ok found '4.828427125', expected '4.828427125', error '0.000000000'
Test #2:
score: 0
Accepted
time: 3ms
memory: 19468kb
input:
0
output:
0.000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #3:
score: 0
Accepted
time: 8ms
memory: 19376kb
input:
1
output:
1.000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 25ms
memory: 20020kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
0.000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #5:
score: -100
Wrong Answer
time: 28ms
memory: 20136kb
input:
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
495833.423792273092
result:
wrong answer 1st numbers differ - expected: '500000.4142136', found: '495833.4237923', error = '0.0083340'