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

求救,我的方法是设 ai为黑桶的倒了i次之后 B / W比值, b1为白桶的倒了i次之后的 B / W比值, 迭带求 ai,知道符合要求,可是连洋例都过不了,谁给提示下吧,代码见内

Posted by xiaox at 2007-02-25 23:21:51 on Problem 2715
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main()
{
	double a1,b1,tag;
	int B,W,C,ans;
	double b,w,c;
	double EX =0.00001f;
	while (scanf("%d%d%d",&B,&W,&C) && B+W+C)
	{
		ans = 1;
		b = 16.0*B; w = W*16; c = C;
		tag = b / w;
		b1 = c / w;
		a1 = (b-c) / (c * w / (c+w));
		while (fabs(b1-a1)>=EX)
		{
			b1 = (w * b1 * (1+a1) + c * a1 * (1+b1)) / (w * (1+a1) + c * (1+b1));
			a1 = ((b-c) * a1 * (1+b1) + c * b1 * (1+a1)) / ((b-c) * (1+b1) + c * (1+a1));
			ans++;
			printf("ans: %d tag: %lf a1: %lf b1: %lf\n",ans,tag,a1,b1);
			//system("PAUSE");
		}
		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