QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#18212 | #2267. Jewelry Size | Realityang# | WA | 3ms | 5896kb | C++14 | 1.0kb | 2022-01-16 20:06:32 | 2022-05-04 17:20:56 |
Judging History
answer
#include<bits/stdc++.h>
#define double long double
using namespace std;
const int N=1000010,mod=1e9+7;
const double eps=1e-12,ee=1e-10;
int n,a[N];
double b[N];
void sun(double r){for(int i=1;i<=n;i++)b[i]=2.0*asin((double)a[i]*0.5/r);sort(b+1,b+n+1);}
signed main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}sort(a+1,a+n+1);
double an1=-1,an2=-1;
double ll=a[n]/2.0,rr=1e5;
while(rr-ll>=eps){
double r=(ll+rr)/2.0,su=0;
sun(r);
for(int i=1;i<=n;i++)su+=b[i];
double j1=su-2.0*acos(-1);
if(j1<0)rr=r;
else ll=r;
}
sun(rr);double ss=0;
for(int i=1;i<=n;i++)ss+=b[i];
double j1=ss-2.0*acos(-1);
if(j1>-ee&&j1<ee)an1=rr;
ll=a[n]/2.0,rr=1e5;
while(rr-ll>=eps){
double r=(ll+rr)/2.0,su=0;
sun(r);
for(int i=1;i<n;i++)su+=b[i];
double j2=b[n]-su;
if(j2<0)rr=r;
else ll=r;
}
sun(rr);ss=0;
for(int i=1;i<n;i++)ss+=b[i];
double j2=b[n]-ss;
if(j2>-ee&&j2<ee)an2=rr;
if(an1==-1.0)cout<<setprecision(10)<<fixed<<an2;
if(an2==-1.0)cout<<setprecision(10)<<fixed<<an1;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 5836kb
input:
5 3 1 6 1 7
output:
3.5444043509
result:
ok found '3.5444044', expected '3.5444044', error '0.0000000'
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 5896kb
input:
3 500 300 400
output:
-1.0000000000-1.0000000000
result:
wrong output format Expected double, but "-1.0000000000-1.0000000000" found