QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#514931 | #2267. Jewelry Size | Cheek_support# | WA | 0ms | 4332kb | C++20 | 1.5kb | 2024-08-11 13:37:26 | 2024-08-11 13:37:26 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
int read(){
char ch=getchar();int x=0,f=1;
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
return f*x;
}
int n;
const double eps=1e-7;
const int N=1000;
const double Pi=acos(-1);
int L[N+10];
double Angle(double r,double b){
return acos((r*r+r*r-b*b)/2.0/r/r);
}
double chk(double mid){
double sum=0;
rep(i,1,n){
sum+=Angle(mid,L[i]);
}
return sum;
}
int main(){
n=read();
rep(i,1,n){
L[i]=read();
}
sort(L+1,L+n+1);
double tmp=chk(L[n]/2.0+eps);
double ll=eps;
double rr=10000.0;
if(tmp>2*Pi||fabs(tmp-2*Pi)<eps){
while(fabs(rr-ll)>eps){
double mid=(ll+rr)/2.0;
if(chk(mid)<2*Pi){
rr=mid;
}else{
ll=mid;
}
}
printf("%.8f\n",(ll+rr)/2);
return 0;
}
ll=L[n]/2.0+eps;
n--;
while(true){
rr=ll*2;
double sum1=chk(rr);
double sum2=Angle(rr,L[n+1]);
if(sum1<sum2){
ll*=2;
}else{
break;
}
}
while(fabs(rr-ll)>eps){
double mid=(ll+rr)/2.0;
if(chk(mid)<Angle(mid,L[n+1])){
ll=mid;
}else{
rr=mid;
}
}
printf("%.8f\n",(ll+rr)/2);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4332kb
input:
5 3 1 6 1 7
output:
3.54440438
result:
ok found '3.5444044', expected '3.5444044', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4240kb
input:
3 500 300 400
output:
250.00000013
result:
ok found '250.0000001', expected '250.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4180kb
input:
8 2000 3000 4000 2000 3000 4000 2000 3000
output:
3780.97412063
result:
ok found '3780.9741206', expected '3780.9741206', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 4164kb
input:
10 602 67 67 67 67 67 67 67 67 67
output:
3003.13981701
result:
ok found '3003.1398170', expected '3003.1398170', error '0.0000000'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 4320kb
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...
output:
9999.99999996
result:
wrong answer 1st numbers differ - expected: '490696.1297935', found: '10000.0000000', error = '0.9796208'