QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18166 | #2267. Jewelry Size | Wu_Ren# | WA | 99ms | 5900kb | C++11 | 774b | 2022-01-16 16:47:47 | 2022-05-04 17:14:43 |
Judging History
answer
#include<bits/stdc++.h>
int mod;
const long double pi=acosl(-1.0);
using namespace std;
int n,m,K;
int a[1000010];
char s[1000010];
long double ans,res=1e18,d;
bool chk(long double x,int k){
long double sum=0,t=2*x*x;
for(int i=1;i<n;i++) sum+=acosl(1-a[i]/t);
if(k) sum+=acosl(1-a[n]/t);
else sum+=2*pi-acosl(1-a[n]/t);
if(labs(sum-2*pi)<=1e-3) ans=x;
return sum<2*pi;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
sort(a+1,a+n+1),d=a[n]/2.0;
for(int i=1;i<=n;i++) a[i]=a[i]*a[i];
for(int k=0;k<2;k++){
ans=1e18;
long double l=d,r=1e18,mid;
for(int _=0;_<100000;_++){
mid=(l+r)/2.0;
if(chk(mid,k)) (k?r:l)=mid;
else (k?l:r)=mid;
}
res=min(res,ans);
}
printf("%.12lf",(double)res);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 57ms
memory: 3764kb
input:
5 3 1 6 1 7
output:
3.544404350919
result:
ok found '3.5444044', expected '3.5444044', error '0.0000000'
Test #2:
score: 0
Accepted
time: 32ms
memory: 5900kb
input:
3 500 300 400
output:
250.000000000000
result:
ok found '250.0000000', expected '250.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 92ms
memory: 5804kb
input:
8 2000 3000 4000 2000 3000 4000 2000 3000
output:
3780.974120599489
result:
ok found '3780.9741206', expected '3780.9741206', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 99ms
memory: 5692kb
input:
10 602 67 67 67 67 67 67 67 67 67
output:
2585570312192.000000000000
result:
wrong answer 1st numbers differ - expected: '3003.1398170', found: '2585570312192.0000000', error = '860955688.6371050'