标签:
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6442 Accepted Submission(s): 2421
1 #include <cmath> 2 #include <cstdio> 3 #include <iostream> 4 #define PI acos(-1.0) 5 //#define PI 3.1415926 不要用这个; 6 using namespace std; 7 double num[10010]; 8 int main() 9 { 10 int t; 11 scanf("%d", &t); 12 while(t--) 13 { 14 int m, n; 15 double max = 0.0; 16 scanf("%d %d", &m, &n); 17 n++; 18 for(int i=0; i<m; i++) 19 { 20 int ti; 21 scanf("%d",&ti); 22 num[i] = PI*ti*ti; 23 if(num[i] > max) 24 max = num[i]; 25 } 26 double min=0.0, mid; 27 while(max - min > 1e-6) 28 { 29 mid=(max + min) / 2.0; 30 int total = 0; 31 for(int i=0; i<m; i++) 32 total += (int)(num[i] / mid); 33 if(total >= n) 34 min = mid; 35 else 36 max = mid; 37 } 38 printf("%.4lf\n",mid); 39 } 40 return 0; 41 }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4699077.html