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 |
这题测试数据坑爹,样例错误都过了~#include<stdio.h> #include<math.h> #define PI 3.14159265358 const int MAXN=10010; int pie[MAXN]; int main() { // freopen("in.txt","r",stdin); int t,n,f,i,tot; double mid,high,low; scanf("%d",&t); while(t--) { low=0,high=-1; scanf("%d%d",&n,&f); f++; for(i=0;i<n;i++){ scanf("%d",&pie[i]); if(pie[i]>high)high=pie[i]; pie[i]*=pie[i]; } for(high*=high+1,mid=(low+high)/2;high-low>1e-4;mid=(low+high)/2){ for(i=0,tot=0;i<n;i++){ tot+=(int)(pie[i]/mid); } tot<f?high=mid:low=mid; } printf("%.4lf\n",mid*PI); } return 0; } 上面那个代码样例错误,居然给过了,,,,SPJ强大啊! 1e-4改成1e-5,样例就没有错了。。。 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator