标签:
题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=42065
#include <cstdio> #include <cmath> using namespace std; const double PI = acos(-1); double v[10005]; int N, F; bool test(double x) { int tot = 0; for(int i=0; i<N; i++) { tot += floor(v[i] / x); } return tot >= F; } int main () { int T, r; scanf("%d", &T); while(T--) { scanf("%d%d", &N, &F); ++F; double lb = 0, ub = -1; for(int i=0; i<N; i++) { scanf("%d", &r); v[i] = PI * r * r; if(v[i] > ub) ub = v[i]; } ub += 1; while(lb + 1e-5< ub) { // [, ) double mid = (lb + ub) / 2; if(test(mid)) lb = mid; else ub = mid; } printf("%.4lf\n", lb); } return 0; }
标签:
原文地址:http://www.cnblogs.com/AcIsFun/p/5289813.html