QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#801402 | #9746. 平方根 | PhoenixRebirth | AC ✓ | 7ms | 12752kb | C++23 | 690b | 2024-12-06 22:52:16 | 2024-12-06 22:52:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
char a[N];
int n;
double f[N];
void gen() {
f[1] = 1;
for (int i = 2; i < N; i++) {
if (i & 1) {
f[i] = (i + 1) / 2;
} else {
f[i] = sqrt(2) + (i - 2) / 2;
}
}
}
int main() {
gen();
scanf("%s", a + 1);
n = strlen(a + 1);
double ans = 0;
int one = 0;
for (int i = 1; i <= n + 1; i++) {
if (i <= n && a[i] == '1') {
one++;
} else if (i == n + 1 || a[i] == '0') {
ans += f[one];
one = 0;
}
}
printf("%.9f\n", ans);
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 11728kb
input:
1100110111
output:
4.828427125
result:
ok found '4.828427125', expected '4.828427125', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 11728kb
input:
0
output:
0.000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 11780kb
input:
1
output:
1.000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 3ms
memory: 12752kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
0.000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #5:
score: 0
Accepted
time: 3ms
memory: 12712kb
input:
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
500000.414213562
result:
ok found '500000.414213562', expected '500000.414213562', error '0.000000000'
Test #6:
score: 0
Accepted
time: 7ms
memory: 12696kb
input:
010101111011001000011101100000011110101010000110011110101010111011010011100001100000001011100111110000100101100011101101000100110100111101001100011000101000000101011101000011011001111011101101100010110110001111011001010100110011111101000010010011011101100001101001101010011011100110101001101111010101...
output:
367851.986787612
result:
ok found '367851.986787612', expected '367851.986787086', error '0.000000000'
Test #7:
score: 0
Accepted
time: 3ms
memory: 12656kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
299931.313708499
result:
ok found '299931.313708499', expected '299931.313708499', error '0.000000000'
Extra Test:
score: 0
Extra Test Passed