QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#501257 | #5152. Circular Caramel Cookie | Abcl | WA | 0ms | 3948kb | C++14 | 846b | 2024-08-02 16:06:13 | 2024-08-02 16:06:13 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
const double hu=3.14159265358*10/4.0;
int n;
double ans;
void solve(){
cin>>n;
int k=0;
double a,b;
if(n==1){
ans=1.4142135624;
printf("%.10lf",ans);
return;}
int f=0;
int minl=1e11;
for(int i=sqrt(1e9) ;i>=0;i--){
if(i*i-n>=0&&(i*i-n)<minl){
minl=i*i-n;
k=i;
}
else break;
}
// cout<<k<<endl;
if(k*k==n){
a=k+2,b=k;
}
else if(k*k-4>=n){
a=k-2,b=k;
}
else {
a=k,b=k;
}
// cout<<a<<" "<<b<<endl;
ans=sqrt(a*a+b*b)/2.0;
printf("%.10lf",ans);
return;
}
signed main() {
// ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T_case=1;
// cin>>T_case;
while(T_case--){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3920kb
input:
11
output:
2.2360679775
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
59
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
1
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
2
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
3
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
4
output:
2.2360679775
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3804kb
input:
1000000000
output:
0.0000000000
result:
wrong answer 1st numbers differ - expected: '17841.8813190', found: '0.0000000', error = '1.0000000'