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

取石子游戏超时怎么改

Posted by yanyikai0214 at 2013-03-08 23:13:07
# include <iostream>
# include <cstdio>
# include <cmath>
using namespace std;
int main()
{
	int d,q;
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		q=0;
		d=0;
		if(a>b)
		{
			int i=a;
			a=b;
			b=i;
		}
		for(int i=0;;i++)
		{
			int c=i*(1+sqrt(5.0))/2;
			if(a==c)
			{
				q=i;
				d=1;
				break;
			}
			if(a==c+i)
			{
				q=i;
				d=2;
				break;
			}
		}
		if(d==2)
		{
			cout<<1<<endl;
			continue;
		}
		if(d==1)
		{
			if(b==a+q)
			{
				cout<<0<<endl;
				continue;
			}
			else
			{
				cout<<1<<endl;
				continue;
			}
		}
	}
	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