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 |
Re:我觉得我的精度够了呀,怎么还老是错?In Reply To:我觉得我的精度够了呀,怎么还老是错? Posted by:xuetry at 2006-12-05 10:05:54 #include <iostream> #include<cmath> using namespace std; double s[10000]; int main() { // freopen("C:\\ACMData.txt","r",stdin); int t,N,F,p,tmp; scanf("%d",&t); double max , min , mid; while(t) { scanf("%d%d",&N,&F); F++; p=0; max = 0; while(p<N){ scanf("%d",&tmp); s[p] = tmp*tmp; if(max < s[p]) max = s[p]; p++; } double mid = max; min =0.0; while(max-min > 0.000001){ p=0; int num=0; while(p<N){ if( s[p] >= mid) num +=(int) (s[p] / mid); p++; if( num > F) break; } if( num>=F) min = mid; else max = mid; mid = (max+min)/2; } double rst = (max+min)/2.0; printf("%.4lf\n",rst*acos(-1)); t--; } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator