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++ TLE,C++ ACHuge input and output data,scanf and printf are recommended. 这就是G++TLE的原因,调用了太多了io接口,以后要调用很多io接口的题还是用C++好 Code: #include <stdio.h> #include <math.h> const double Exp=0.00001; double b,w,c; int main(){ while(scanf("%lf%lf%lf",&b,&w,&c),b+w+c!=0){ b*=16; w*=16; double ratio_B=1,ratio_W=0; int ans=0; while(fabs(ratio_B/(1-ratio_B)-b/w)>Exp||fabs(ratio_W/(1-ratio_W)-b/w)>Exp){ ratio_W=1-(w-w*ratio_W+c-c*ratio_B)/(c+w); ratio_B=((b-c)*ratio_B+c*ratio_W)/b; ++ans; } printf("%d\n",ans); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator