QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#154144 | #5152. Circular Caramel Cookie | acm202226010311 | WA | 1ms | 3748kb | C++14 | 947b | 2023-08-31 14:08:00 | 2023-08-31 14:08:00 |
Judging History
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'