QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#154114#5152. Circular Caramel Cookieacm202226010311WA 1ms3588kbC++14820b2023-08-31 13:46:092023-08-31 13:46:10

Judging History

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

  • [2023-08-31 13:46:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3588kb
  • [2023-08-31 13:46:09]
  • 提交

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);
	for(int i=b;i<=e;i++)
	{
		if(num(i)>=n)
		{
			cout<<fixed<<setprecision(10)<<sqrt(i);
			break;
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

11

output:

l2 r3
2.2360679775

result:

wrong output format Expected double, but "l2" found