QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#754984#9746. 平方根huang123zsWA 0ms3952kbC++14778b2024-11-16 16:11:362024-11-16 16:11:36

Judging History

This is the latest submission verdict.

  • [2024-11-16 16:11:36]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3952kb
  • [2024-11-16 16:11:36]
  • Submitted

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'