QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#154104 | #5152. Circular Caramel Cookie | acm202226010311 | WA | 2ms | 3624kb | C++14 | 654b | 2023-08-31 13:40:01 | 2023-08-31 13:40:02 |
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;
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;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3580kb
input:
11
output:
2.2360679775
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
59
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3480kb
input:
1
output:
result:
wrong output format Unexpected end of file - double expected