QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#754999 | #9746. 平方根 | huang123zs | AC ✓ | 7ms | 4936kb | C++14 | 800b | 2024-11-16 16:14:09 | 2024-11-16 16:14:09 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=1.1e6;
inline LL read(){
LL x=0,ff=1;
char c=getchar();
while(!isdigit(c)&&c!='-') c=getchar();
if(c=='-') c=getchar(),ff=-1;
while(isdigit(c)) x=x*10ll+c-'0',c=getchar();
return x*ff;
}
int n;
char c[N];
int main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
scanf("%s",c+1);
n=strlen(c+1);
int sum=0;
double ans=0,val=sqrt(2.0);
// printf("%.8lf\n",val);
for(int i=1;i<=n;++i){
if(c[i]=='1')
++sum;
else if(sum!=0){
if(sum&1)
ans+=(sum+1)/2.0;
else
ans+=sum/2-1+val;
// printf("%d %.8lf\n",i,ans);
sum=0;
}
}
if(sum!=0){
if(sum&1)
ans+=(sum+1)/2;
else
ans+=sum/2-1+val;
}
printf("%.8lf\n",ans);
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3956kb
input:
1100110111
output:
4.82842712
result:
ok found '4.828427120', expected '4.828427125', error '0.000000001'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
0
output:
0.00000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
1
output:
1.00000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 3ms
memory: 4868kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
0.00000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 4932kb
input:
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
500000.41421356
result:
ok found '500000.414213560', expected '500000.414213562', error '0.000000000'
Test #6:
score: 0
Accepted
time: 7ms
memory: 4880kb
input:
010101111011001000011101100000011110101010000110011110101010111011010011100001100000001011100111110000100101100011101101000100110100111101001100011000101000000101011101000011011001111011101101100010110110001111011001010100110011111101000010010011011101100001101001101010011011100110101001101111010101...
output:
367851.98678761
result:
ok found '367851.986787610', expected '367851.986787086', error '0.000000000'
Test #7:
score: 0
Accepted
time: 3ms
memory: 4936kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
299931.31370850
result:
ok found '299931.313708500', expected '299931.313708499', error '0.000000000'
Extra Test:
score: 0
Extra Test Passed