QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#154144#5152. Circular Caramel Cookieacm202226010311WA 1ms3748kbC++14947b2023-08-31 14:08:002023-08-31 14:08:00

Judging History

你现在查看的是最新测评结果

  • [2023-08-31 14:08:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3748kb
  • [2023-08-31 14:08:00]
  • 提交

answer

#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
int num(int a)//a代表r*r 
{
	int res=0;
	for(int i=int(sqrt(a));i>0;i--)
	res+=int(sqrt(a-i*i));
	res*=4;
	return res;
}
int main()
{
	int n;
	cin>>n;
	if(n<=3)
	{
		cout<<fixed<<setprecision(10)<<sqrt(2)<<endl;
		return 0;
	}
	if(n>=4&&n<=7)
	{
		cout<<fixed<<setprecision(10)<<sqrt(5)<<endl;
		return 0;
	}
	n++;
	int r=sqrt(n);
	int l=r/3;
	int mid;
	while(l<r)
	{
		mid=(l+r)/2;
		int t=num(mid*mid); 
		if(t>=n)r=mid;
		if(t<=n)l=mid;
		//cout<<"l"<<l<<" "<<"r"<<r<<endl;
		if(l+1==r)break;
	}
	mid=(l+r)/2;
	int b=mid*mid;
	int e=(mid+1)*(mid+1);
	int in;
	while(b<e)
	{
		in=(b+e)/2;
		int t=num(in);
		if(t>=n)e=in;
		if(t<=n)b=in;
		if(b+1==e)break;
	}
	in=(b+e)/2;
	if(num(in)>=n)cout<<fixed<<setprecision(10)<<sqrt(in);
	else cout<<fixed<<setprecision(10)<<sqrt(in+1);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3748kb

input:

11

output:

2.4494897428

result:

wrong answer 1st numbers differ - expected: '2.2360680', found: '2.4494897', error = '0.0954451'