| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
G=++wa c++ ac 0.o 这题有毒#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#define PI atan(1.0)*4.0
using namespace std;
double a[10005];
double volume(double x){
return PI*x*x;
}
int main(){
int t,m,n;
scanf("%d",&t);
while(t--){
scanf("%d%d",&m,&n);
for(int i=0;i<m;i++)
scanf("%lf",&a[i]);
sort(a,a+m);
double l=0,r=volume(a[m-1]),mid;
while(1){
int sum=0;
mid=(l+r)/2;
for(int i=0;i<m;i++)
sum+=volume(a[i])/mid;//(int)(volume(a[i])/mid+1e-10);后者竟然是错.....
if(sum<(n+1)) r=mid;
else l=mid;
if(fabs(l-r)<1e-6){
printf("%.4lf\n",mid);
break;
}
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator