https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1636
http://7xjob4.com1.z0.glb.clouddn.com/7f2d26dff99d9cc95e81c18e10aea4f5
题意:每个人分到面积相同的整块派,求能分到的最大面积
思路:二分查找面积为x的派看是否能分足够的块数
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const double pi=acos(-1.0); 5 6 int r; 7 int n,f; 8 double s[10005]; 9 10 int check(double c) 11 { 12 int i,j,sum=0; 13 for(i=1;i<=n;i++) 14 sum+=floor(s[i]/c); 15 if(sum>=f+1) 16 return 1; 17 else 18 return 0; 19 } 20 21 int main() 22 { 23 int T; 24 int i,j; 25 scanf("%d",&T); 26 while(T--) 27 { 28 double L=0,R=0; 29 scanf("%d %d",&n,&f); 30 for(i=1;i<=n;i++) 31 { 32 scanf("%d",&r); 33 s[i]=pi*r*r; 34 R=max(R,s[i]); 35 } 36 37 while(R-L>1e-5) 38 { 39 double M=(L+R)/2; 40 if(check(M)==1) 41 L=M; 42 else 43 R=M; 44 } 45 printf("%f ",L); 46 } 47 return 0; 48 }