每周花费
#include<cstdio> #include<algorithm> #include<cmath> using namespace std; #define PI acos(-1) #define EPS 1e-6 double B[10000]; int main(){ int n,N,f,r; double left=0,right=0; scanf("%d",&n); while(n--){ scanf("%d%d",&N,&f); for(int i=1;i<=N;i++){ scanf("%d",&r); B[i]=PI*r*r; if(right<B[i])right=B[i]; } while(right-left>=EPS){ double mid=(right+left)/2.0; int sum=0; for(int i=1;i<=N;i++){ sum+=(int)(B[i]/mid); } if(sum>=f+1)left=mid; else right=mid; } printf("%.4lf\n",left); left=0; } return 0; }