Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这题测试数据坑爹,样例错误都过了~

Posted by zhsl at 2012-03-11 00:56:16 on Problem 3122 and last updated at 2012-03-11 00:57:05
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358
const int MAXN=10010;
int pie[MAXN];
int main()
{
//	freopen("in.txt","r",stdin);
	int t,n,f,i,tot;
	double mid,high,low;
	scanf("%d",&t);
	while(t--)
	{
		low=0,high=-1;
		scanf("%d%d",&n,&f);
		f++;

		for(i=0;i<n;i++){
			scanf("%d",&pie[i]);
			if(pie[i]>high)high=pie[i];
			pie[i]*=pie[i];
		}

		for(high*=high+1,mid=(low+high)/2;high-low>1e-4;mid=(low+high)/2){
			for(i=0,tot=0;i<n;i++){
				tot+=(int)(pie[i]/mid);
			}
			tot<f?high=mid:low=mid;
		}
		printf("%.4lf\n",mid*PI);
	}
	return 0;
}

上面那个代码样例错误,居然给过了,,,,SPJ强大啊!
1e-4改成1e-5,样例就没有错了。。。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator