QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#18092 | #2267. Jewelry Size | cccpy | WA | 3ms | 4324kb | C++11 | 860b | 2022-01-16 10:58:40 | 2022-05-04 17:04:08 |
Judging History
answer
#include<bits/stdc++.h>
#define db double
#define pi acos(-1)
#define MAX 1005
using namespace std;
const double eps=1e-9;
const long long inf=1e8;
int n;
db a[MAX],b[MAX],ans,ret1,ret2;
bool check(double x,int type){
double ret=0,tx=2*x*x;
for(int i=1;i<=n-1;i++)
ret+=acos((tx-b[i])/tx);
if(type==1) ret+=acos((tx-b[n])/tx);
else ret+=2*pi-acos((tx-b[n])/tx);
if(abs(ret-2*pi)<=1e-3) 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]),b[i]=a[i]*a[i];
sort(a+1,a+1+n);
ans=min(ck(1),ck(2));
printf("%.8lf",ans);
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 4324kb
input:
5 3 1 6 1 7
output:
3.54440435
result:
ok found '3.5444044', expected '3.5444044', error '0.0000000'
Test #2:
score: 0
Accepted
time: 3ms
memory: 4228kb
input:
3 500 300 400
output:
250.00000000
result:
ok found '250.0000000', expected '250.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 3ms
memory: 4216kb
input:
8 2000 3000 4000 2000 3000 4000 2000 3000
output:
3780.97412060
result:
ok found '3780.9741206', expected '3780.9741206', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 3ms
memory: 4144kb
input:
10 602 67 67 67 67 67 67 67 67 67
output:
1562796.29687500
result:
wrong answer 1st numbers differ - expected: '3003.1398170', found: '1562796.2968750', error = '519.3874585'