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

## Re: 精度啊 ！！！挖了n次之后终于AC了 以下是代码可以看出对精度要求是多么苛刻

Posted by Dream_Learner at 2010-07-18 14:08:22 on Problem 1064
In Reply To: 精度啊 ！！！挖了n次之后终于AC了 以下是代码可以看出对精度要求是多么苛刻 Posted by:guangming1987 at 2009-01-18 01:39:07
```> 还是对精度的了解不够深啊   真难控制
>
> #include <iostream>
> #include <algorithm>
> using namespace std;
> double t;
> __int64 num[100000],start,mid,end;__int64 sum,n,k;
> int main(){
> 	__int64 i;
> 	while(scanf("%I64d%I64d",&n,&k)!=-1){
> 		for(i=0;i<n;i++){
> 			scanf("%lf",&t);
> 			t*=100;
> 			num[i]=int(t);
> 			sum+=num[i];
> 		}
> 		if(sum<k){printf("0.00\n");continue;}
> 		sort(num,num+n);
> 		start=1;end=num[0];
> 		while(start+1<end){
> 			sum=0;
> 			mid=(start+end)/2;
> 			for(i=0;i<n;i++)sum+=num[i]/mid;
> 			if(sum<k)end=mid;
> 			if(sum>=k)start=mid;
> 		}
> 		sum=0;
> 		for(i=0;i<n;i++)sum+=num[i]/end;
> 		if(sum>=k)printf("%.2lf\n",end*0.01);
> 		else printf("%.2lf\n",start*0.01);
> 	}
> 	return 0;
> }
> /*
> 4 11
> 8.02
> 7.43
> 4.57
> 5.39
> */
```

Followed by: