QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18150#2267. Jewelry Size2022zll#WA 2ms2580kbC++111.4kb2022-01-16 15:51:252022-05-04 17:13:17

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 17:13:17]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:2580kb
  • [2022-01-16 15:51:25]
  • 提交

answer

#include<cmath>
#include<cstdio>
typedef long double real;
int read(){
	int ch=getchar(),num=0;
	while(ch<48||ch>57)ch=getchar();
	while(ch>=48&&ch<=57)num=(num<<3)+(num<<1)+(ch^48),ch=getchar();
	return num;
}
const int maxn=1005;
const real eps=1e-15,pi=acos(-1);
int n,max_id=1,min_id=1;
real a[maxn],angle[maxn],sum;
real bs1(){
	real l=a[max_id],r=1e6,m;
	while(r-l>1e-10){
		m=(l+r)/2,sum=0;
		for(int i=1;i<=n;i++){
			angle[i]=asin(a[i]/m);
			sum+=angle[i];
		}
		if(sum<pi)r=m;
		else l=m;
	}
//	printf("bs1:  l=%Lf\n",l);
//	printf("sum=%.10Lf\n",sum);
	return(fabs(sum-pi)<1e-5||m-a[max_id]>eps*100)?l:1e100;
}
real calc(real m){
	sum=0;
	for(int i=1;i<=n;i++){
		angle[i]=asin(a[i]/m);
		sum+=angle[i];
	}
	return fabs(sum-angle[max_id]*2);
}
real bs2(){
	/*real x;
	while(scanf("%Lf",&x)){
		printf("%.20Lf\n",calc(x)*x);
	}*/
	real l=a[max_id],r=1e6,ml,mr;
	while(r-l>1e-8){
		ml=(l+l+r)/3,mr=(l+r+r)/3;
//		printf("%.16Lf %.16Lf %.16Lf %.16Lf\n",l,ml,mr,r);
		real vl=calc(ml)*ml,vr=calc(mr)*mr;
//		printf("%.10Lf  %.10Lf\n",vl,vr);
		if(vl<vr)r=mr;
		else l=ml;
	}
//	printf("bs2:  l=%.10Lf\n",l);
	return fabs(calc(l))<1e-5?l:1e100;
}
real min(real a,real b){
	return a<b?a:b;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read()/2.0;
		if(a[max_id]<a[i])max_id=i;
		if(a[min_id]>a[i])min_id=i;
	}
	printf("%.10Lf\n",min(bs1(),bs2()));
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 2580kb

input:

5
3 1 6 1 7

output:

3.5444043509

result:

ok found '3.5444044', expected '3.5444044', error '0.0000000'

Test #2:

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

input:

3
500 300 400

output:

250.0000000000

result:

ok found '250.0000000', expected '250.0000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 2168kb

input:

8
2000 3000 4000 2000 3000 4000 2000 3000

output:

3780.9741205995

result:

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

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 2428kb

input:

10
602 67 67 67 67 67 67 67 67 67

output:

301.0000000000

result:

wrong answer 1st numbers differ - expected: '3003.1398170', found: '301.0000000', error = '0.8997716'