题目:http://poj.org/problem?id=3122
这个题就好多了,没有恶心的精度问题,所以1A了。。
1 #include <stdio.h> 2 #include <math.h> 3 4 const double PI = acos(-1); 5 int r[10010], t, n, m; 6 7 int main() 8 { 9 scanf("%d", &t); 10 while(t--) 11 { 12 double low = 0, high = 0; 13 scanf("%d %d", &n, &m); 14 for(int i = 0; i < n; i++) 15 { 16 scanf("%d", &r[i]); 17 high += PI * r[i] * r[i]; 18 } 19 high /= m+1; 20 while(high - low > 1e-6) 21 { 22 double mid = (high + low) / 2; 23 int cnt = 0; 24 for(int i = 0; i < n; i++) 25 { 26 cnt += PI * r[i] * r[i] / mid; 27 } 28 if(cnt >= m+1) 29 { 30 low = mid; 31 } 32 else 33 { 34 high = mid; 35 } 36 } 37 printf("%.4f ", low); 38 } 39 return 0; 40 }