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代码

Posted by endkiller at 2010-09-03 21:49:05 on Problem 2348 and last updated at 2010-09-03 21:56:46
#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:
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