QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#18084 | #2267. Jewelry Size | ccpy# | TL | 0ms | 0kb | C++11 | 896b | 2022-01-16 10:43:56 | 2022-05-04 17:03:26 |
Judging History
answer
#include<bits/stdc++.h>
#define db double
#define pi acos(-1)
#define MAX 1005
using namespace std;
const double eps=1e-10;
const long long inf=1e10;
int n;
db a[MAX],ans,ret1,ret2;
bool check(double x,int type){
double ret=0;
for(int i=1;i<=n-1;i++)
ret+=acos((2*x*x-a[i]*a[i])/(2*x*x));
if(type==1) ret+=acos((2*x*x-a[n]*a[n])/(2*x*x));
else ret+=2*pi-acos((2*x*x-a[n]*a[n])/(2*x*x));
if(abs(ret-2*pi)<=1e-5) type==1?ret1=x:ret2=x;
if(ret>=2*pi) return 0;
return 1;
}
double ck(int type){
double l=a[n]/2,r;
r=inf;
type==1?ret1=inf:ret2=inf;
while(l<r-eps){
double mid=(l+r)/2;
if(check(mid,type)) type==1?r=mid:l=mid;
else type==1?l=mid:r=mid;
}
return type==1?ret1:ret2;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%lf",&a[i]);
sort(a+1,a+1+n);
ans=min(ck(1),ck(2));
check(3003.13981697,2);
printf("%.8lf",ans);
}
详细
Test #1:
score: 0
Time Limit Exceeded
input:
5 3 1 6 1 7