QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18092#2267. Jewelry SizecccpyWA 3ms4324kbC++11860b2022-01-16 10:58:402022-05-04 17:04:08

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:04:08]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4324kb
  • [2022-01-16 10:58:40]
  • 提交

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'