阅读背景:

【POJ 2348】Euclid's Game 【简单博弈】

来源:互联网 

可以用搜索的姿势写过。

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

long long a,b;

bool Judge(int a,int b)
{
	if(a < b)	swap(a,b);
	if(!b)	return false;
	int end = a / b;
	for(int i = end; i >= 1; --i)
		if(!Judge(a - i * b,b))
			return true;
	return false;
}

int main()
{
	long long x,y;
	while(scanf("%lld%lld",&x,&y),x + y)
		printf("%s\n",Judge(x,y) ? "Stan wins":"Ollie wins");
}#include <cstdio>
#include <cs



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: