| ||||||||||
| 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 | |||||||||
做了好久,终于AC了,附:我的AC程序//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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator