QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#154114 | #5152. Circular Caramel Cookie | acm202226010311 | WA | 1ms | 3588kb | C++14 | 820b | 2023-08-31 13:46:09 | 2023-08-31 13:46:10 |
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);
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