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

Re:1e-7过了,不过是在UVA...

Posted by sharang at 2006-12-05 12:00:52 on Problem 3122
In Reply To:我觉得我的精度够了呀,怎么还老是错? Posted by:xuetry at 2006-12-05 10:05:54
> #include <iostream>
> using namespace std;
> double s[10000];
> int main()
> {
> //	freopen("C:\\ACMData.txt","r",stdin);
> 	int t,N,F,p,tmp;  
> 	scanf("%d",&t);
> 	while(t)
> 	{
>         scanf("%d%d",&N,&F); F++;
>         p=0;
> 		while(p<N){
> 			scanf("%d",&tmp);  s[p] = (double)tmp*(double)tmp;
> 			p++;
> 		}
>         double max = 100000000.0; double min =0.0;
> 		while(max-min > 0.000001){
> 			double mid =(max+min)/2.0;
> 			p=0;  int num=0;
> 			while(p<N){
> 				if( s[p] >= mid)
>                      num +=(int) (s[p] / mid);
> 			   p++;
> 			   if( num > F)
> 				   break;
> 			}
> 			if( num>=F)
> 				min = mid;
> 			else
> 				max = mid;
> 		}
> 		double rst = (max+min)/2.0;
> 		printf("%.5lf\n",rst*3.14159265);
> 		t--;
> 	}
> 	return 1;
> }

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