QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#514949#2267. Jewelry SizeCheek_support#WA 1ms4368kbC++201.5kb2024-08-11 13:44:232024-08-11 13:44:23

Judging History

你现在查看的是最新测评结果

  • [2024-08-11 13:44:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4368kb
  • [2024-08-11 13:44:23]
  • 提交

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((double)L[n]/2.0+eps);
    double ll=(double)L[n]/2.0+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;
    }
    
    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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4328kb

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: 4192kb

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: 4072kb

input:

8
2000 3000 4000 2000 3000 4000 2000 3000

output:

3780.97412059

result:

ok found '3780.9741206', expected '3780.9741206', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 4356kb

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: 1ms
memory: 4368kb

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.99999997

result:

wrong answer 1st numbers differ - expected: '490696.1297935', found: '10000.0000000', error = '0.9796208'