QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#18176 | #2267. Jewelry Size | Wu_Ren# | TL | 49ms | 5800kb | C++11 | 769b | 2022-01-16 16:58:47 | 2022-05-04 17:15:59 |
Judging History
answer
#include<bits/stdc++.h>
int mod;
const long double pi=acos(-1);
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(fabsl(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=1e10,mid;
for(int _=0;_<40000;_++){
mid=(l+r)/2;
if(chk(mid,k)) (k?r:l)=mid;
else (k?l:r)=mid;
}
res=min(res,ans);
}
printf("%.12lf",(double)res);
}
詳細信息
Test #1:
score: 100
Accepted
time: 25ms
memory: 3868kb
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: 17ms
memory: 5760kb
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: 39ms
memory: 3784kb
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: 0
Accepted
time: 49ms
memory: 5800kb
input:
10 602 67 67 67 67 67 67 67 67 67
output:
3003.139816965297
result:
ok found '3003.1398170', expected '3003.1398170', error '0.0000000'
Test #5:
score: -100
Time Limit Exceeded
input:
1000 4719 3755 2542 1190 5557 3641 5426 1578 5247 3181 3524 983 4151 4337 3004 2062 1048 4739 499 2530 1378 450 5459 651 1714 4051 416 4186 2598 1031 374 5523 4787 1122 4919 2549 4763 4345 2333 4009 5732 5857 3198 3882 2399 4409 4151 3447 1353 4650 4184 2731 3307 3642 3383 5021 5899 2005 3206 702 30...