QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#754984 | #9746. 平方根 | huang123zs | WA | 0ms | 3952kb | C++14 | 778b | 2024-11-16 16:11:36 | 2024-11-16 16:11:36 |
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&1)
ans+=(sum+1)/2;
else
ans+=sum/2-1+val;
printf("%.8lf\n",ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3940kb
input:
1100110111
output:
4.82842712
result:
ok found '4.828427120', expected '4.828427125', error '0.000000001'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3952kb
input:
0
output:
0.41421356
result:
wrong answer 1st numbers differ - expected: '0.0000000', found: '0.4142136', error = '0.4142136'