| ||||||||||
| 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  | |||||||||
大数据表示并不是必须的,附代码解法,必胜状态的递归搜索
#include <cstdio>
#include <algorithm>
using namespace std;
bool getR(int a, int b){
	if(!a)	return false;
	if(b % a == 0)	return true;
	int c = b / a;
	bool ans = false;
	for(int i = c; i >= 1; i--){
		int newb = b - a * i;
		ans |= !getR(min(a, newb), max(a, newb));
		if(ans)	break;
	}
	return ans;
}
int main(){
	int a, b;
	while(~scanf("%d%d", &a, &b) && a){
		if(a > b)	swap(a, b);
		bool ans = getR(a, b);
		printf("%s wins\n", ans ? "Stan" : "Ollie");
	}
	return 0;
}
Followed by: Post your reply here:  | 
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator