标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2473 Accepted Submission(s): 922
1 #include<stdio.h> 2 double m[10010]; 3 int N;double sum,K; 4 double search(){int temp=0; 5 double l=0,r=sum/K,mid; 6 while(r-l>1e-3){temp=0; 7 mid=(l+r)/2; 8 for(int i=0;i<N;++i)temp+=(int)(m[i]/mid);//temp代表能裁剪成的数量。。。 9 if(temp>=K)l=mid; 10 else r=mid; 11 } 12 return mid; 13 } 14 int main(){ 15 while(scanf("%d%lf",&N,&K),N||K){sum=0; 16 for(int i=0;i<N;++i)scanf("%lf",&m[i]),sum+=m[i]; 17 printf("%.2lf\n",search()); 18 } 19 return 0; 20 }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4689689.html