标签:
| Time Limit: 1000MS | Memory Limit: 65536K | |||
| Total Submissions: 13564 | Accepted: 4650 | Special Judge | ||
Description
My birthday is coming up and traditionally I‘m serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This should be one piece of one pie, not several small pieces since that looks messy. This piece can be one whole pie though. Input
Output
Sample Input
3 3 3 4 3 3 1 24 5 10 5 1 4 2 3 4 5 6 5 4 2
Sample Output
25.1327 3.1416 50.2655
Source
1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring> 5 #include<cstdlib> 6 #include<cmath> 7 #include<vector> 8 #include<iomanip> 9 #include<queue> 10 #include<stack> 11 using namespace std; 12 #define N 10000 13 #define PI 3.1415926535897932384626 14 double r[N],v,d,c,ma; 15 int main(){ 16 //freopen("in.txt","r",stdin); 17 std::ios::sync_with_stdio(false); 18 cin>>c; 19 while(c--){ 20 int n,f; 21 cin>>n>>f; 22 f++; 23 ma=0.0; 24 for(int i=0;i<n;i++){ 25 cin>>r[i]; 26 r[i]*=r[i]; 27 if(ma<r[i]) ma=r[i]; 28 } 29 double up,low,mid; 30 low=0.0;up=ma; 31 while(up-low>1e-6){ 32 mid=(up+low)/2; 33 int num=0; 34 for(int i=0;i<n;i++) 35 num+=(int)(r[i]/mid); 36 if(num>=f) 37 low=mid; 38 else 39 up=mid; 40 } 41 cout<<fixed<<setprecision(4)<<mid*PI<<endl; 42 } 43 return 0; 44 }
标签:
原文地址:http://www.cnblogs.com/yoyo-sincerely/p/5029735.html