Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

G++ TLE,C++ AC

Posted by kuaichenyang at 2015-11-23 14:47:13 on Problem 2715
Huge 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator