Euclid's Game

博弈论

如果a/b>=2则先手必胜,否则就对(b,a-b)的情况取反 a可以整除b的时候也是必赢的

要保证a>b

#include<bits/stdc++.h> 
#define ll long long
using namespace std;

ll a,b;


int main()
{
	while(cin>>a>>b)
	{
		if(a==0 && b==0)	break;
		
		int times = 1;
			if(a<b)
				swap(a,b);
		while(a%b && a/b==1)
		{
			a-=b;
			if(a<b)
				swap(a,b);
			times^=1;
	
		}
		if(!times)
			cout << "Ollie wins" << endl;
		else 
			cout << "Stan wins" << endl; 	
	}
	
	return 0;
}

uva 10368

原文地址:https://www.cnblogs.com/xxrlz/p/10540283.html