Skip to content

Instantly share code, notes, and snippets.

@taruta811
Created October 14, 2011 18:05
Show Gist options
  • Save taruta811/1287846 to your computer and use it in GitHub Desktop.
Save taruta811/1287846 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# coding:utf-8
import fractions
a,b,n = map(int,raw_input().split())
turn = 0
while n>=0:
if turn==0:
n-=fractions.gcd(a,n)
else:
n-=fractions.gcd(b,n)
turn = 1-turn
if turn==0:
print 0
else:
print 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment