Skip to content

Instantly share code, notes, and snippets.

@mob5566
Created July 21, 2015 06:44
Show Gist options
  • Save mob5566/67a3631227f699479ab0 to your computer and use it in GitHub Desktop.
Save mob5566/67a3631227f699479ab0 to your computer and use it in GitHub Desktop.
10368 - Euclid's Game
/**
* Tittle: 10368 - Euclids Game
* Author: Cheng-Shih, Wong
* Date: 2015/07/21
*/
// include files
#include <bits/stdc++.h>
using namespace std;
// definitions
#define FOR(i,a,b) for( int i=(a),_n=(b); i<=_n; ++i )
#define clr(x,v) memset( x, v, sizeof(x) )
// declarations
int a, b;
// functions
bool win( int a, int b )
{
if( a%b == 0 ) return true;
bool ret = false;
ret |= !win( b, a%b );
if( a/b > 1 )
ret |= !win( a%b+b, b );
return ret;
}
// main function
int main( void )
{
while( scanf( "%d%d", &a, &b )==2 && (a|b) ) {
if( a < b ) swap( a, b );
printf( "%s wins\n", win(a,b) ? "Stan":"Ollie" );
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment