QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#779647 | #9746. 平方根 | Nlll# | AC ✓ | 15ms | 12188kb | C++17 | 670b | 2024-11-24 20:43:18 | 2024-11-24 20:43:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int Maxn = 1e6 + 5;
double f[Maxn];
void solve()
{
string s;
cin >> s;
int n = s.length();
double ans = 0;
int cnt = 0;
f[0] = 0;
f[1] = 1;
for(int i = 2; i <= n; i++)
{
f[i] = max(sqrt(i), f[i - 2] + 1.0);
}
for(int i = 0; i < n; i++)
{
if(s[i] == '1')
{
cnt++;
}
if(s[i] == '0' || i == n - 1)
{
ans += f[cnt];
cnt = 0;
}
}
printf("%.15lf\n", ans);
}
int main()
{
//cin.tie(0)->sync_with_stdio(false);
solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
input:
1100110111
output:
4.828427124746190
result:
ok found '4.828427125', expected '4.828427125', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
0
output:
0.000000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
1
output:
1.000000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 12ms
memory: 12180kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
0.000000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #5:
score: 0
Accepted
time: 12ms
memory: 12060kb
input:
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
500000.414213562384248
result:
ok found '500000.414213562', expected '500000.414213562', error '0.000000000'
Test #6:
score: 0
Accepted
time: 15ms
memory: 12188kb
input:
010101111011001000011101100000011110101010000110011110101010111011010011100001100000001011100111110000100101100011101101000100110100111101001100011000101000000101011101000011011001111011101101100010110110001111011001010100110011111101000010010011011101100001101001101010011011100110101001101111010101...
output:
367851.986787611502223
result:
ok found '367851.986787612', expected '367851.986787086', error '0.000000000'
Test #7:
score: 0
Accepted
time: 15ms
memory: 12048kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
299931.313708499015775
result:
ok found '299931.313708499', expected '299931.313708499', error '0.000000000'
Extra Test:
score: 0
Extra Test Passed