标签:
3 3 3 4 3 3 1 24 5 10 5 1 4 2 3 4 5 6 5 4 2
25.1327 3.1416 50.2655
#include <iostream> #include<algorithm> #include<cmath> #include<cstdio> using namespace std; int t,n,f,i,num,x; double pi=acos(-1.0); //不能写3.1415926 double l,r,mid; double s[10005]; int cmp(double a,double b) { return a>b; } int main() { scanf("%d",&t); for(;t>0;t--) { scanf("%d%d",&n,&f); f++; double maxn=0,sum=0; for(i=1;i<=n;i++) { scanf("%d",&x); s[i]=pi*x*x; maxn=max(maxn,s[i]); sum=sum+s[i]; } l=maxn/f; r=sum/f; while(l+0.00001<r) { mid=(l+r)/2; num=0; for(i=1;i<=n;i++) num+=(int)(s[i]/mid); if (num>=f) l=mid; if (num<f) r=mid; } printf("%.4lf\n",l); //printf("%lf\n",acos(-1.0));; } return 0; }
标签:
原文地址:http://www.cnblogs.com/stepping/p/5669072.html