poj Pie

http://poj.org/problem?id=3122

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<cmath>
 4 #define maxn 10010
 5 #include<algorithm>
 6 using namespace std;
 7 
 8 const double pi=acos(-1.0);
 9 const double eps=1e-8;
10 double r[maxn];
11 int n,f;
12 
13 int main()
14 {
15     int t;
16     scanf("%d",&t);
17     while(t--){
18         double max1=0;
19         scanf("%d%d",&n,&f);
20         f++;
21         for(int i=0; i<n; i++)
22         {
23             scanf("%lf",&r[i]);
24             r[i]*=r[i];
25             if(max1<r[i])
26             max1=r[i];
27         }
28         double low=0,high=max1,mid;
29         while(high-low>eps)
30         {
31             mid=(high+low)/2;
32             int ans=0;
33             for(int i=0; i<n; i++)
34                 ans+=(int)(r[i]/mid);
35             if(ans<f)
36                 high=mid;
37             else
38                 low=mid;
39         }
40         printf("%.4lf\n",pi*mid);
41     }
42     return 0;
43 }
View Code

 

posted @ 2013-09-20 20:49  null1019  阅读(154)  评论(0编辑  收藏  举报