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

做了好久,终于AC了,附:我的AC程序

Posted by mwy5ym at 2008-07-28 14:24:22 on Problem 2348 and last updated at 2008-07-28 14:37:28
//2348	Euclid's Game	
#include<stdio.h>
int  min,max,temp;
bool swin;//swin==1可以理解为stan赢,也可以理解为轮到stan操作了
void check()
{
	if(swin)printf("Stan wins\n");
	else printf("Ollie wins\n");
}
int main()
{
	while(1)
	{
		scanf("%d%d",&max,&min);
		if(min==0&&max==0)break;
		if(max<min){temp=max;max=min;min=temp;}
		swin=1;
		while(1)
		{
			if(max/min>1){check();break;}//若大数是小数的2倍或2倍以上,则有操作权的人胜利;若大数是小数的1.x倍,则只有一种减的方法,如下行所示;
			temp=max%min;	max=min;	min=temp;
			if(min==0){check();break;}//<--题意的胜利条件
			swin=!swin;//减完后,操作权移到另一个人手里
		}
	}
	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