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:1e-7过了,不过是在UVA...In Reply To:我觉得我的精度够了呀,怎么还老是错? Posted by:xuetry at 2006-12-05 10:05:54 > #include <iostream> > using namespace std; > double s[10000]; > int main() > { > // freopen("C:\\ACMData.txt","r",stdin); > int t,N,F,p,tmp; > scanf("%d",&t); > while(t) > { > scanf("%d%d",&N,&F); F++; > p=0; > while(p<N){ > scanf("%d",&tmp); s[p] = (double)tmp*(double)tmp; > p++; > } > double max = 100000000.0; double min =0.0; > while(max-min > 0.000001){ > double mid =(max+min)/2.0; > 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; > } > double rst = (max+min)/2.0; > printf("%.5lf\n",rst*3.14159265); > 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