| ||||||||||
| 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代码#include<cstdio>
#include<iostream>
int check(int a,int b)
{
    if(a<b) { int t=a;a=b;b=t;}
	if(b==0) return 0;
	if(a/b>=2) return 1;
	if(check(b,a%b)) return 0;
    return 1;
}
int main()
{
	int a,b,i;
	while(scanf("%d%d",&a,&b)&&(a||b)){
		if(check(a,b)) printf("Stan wins\n");
		else printf("Ollie wins\n");
	}
}
这里说一下为什么a>=2*b当前选手一定赢。举一个例子就知道了。
27 5
不管怎么操作都会得到状态2 5,如果2 5是胜态的话,那么先手就可以选择到7 5,下一个选手必然要选2 5,假如2 5是负态的话,先手就可以选择到2 5.
Followed by: Post your reply here:  | 
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator