
 229通过
 426提交
 题目来源 CodeForces 119A
 评测方式 RemoteJudge
 标签 最大公约数,gcd 模拟
 难度 入门难度
 时空限制 2000ms / 256MB
最新讨论 显示
题意翻译
题目描述
Simon和Antisimon在玩石子游戏。
共有n颗石子，Simon先拿。
Simon能拿当前n和a的最大公约数，Antisimon能拿当前n和b的最大公约数。
当有一个人不能拿时（n=0）那个人就输了。
求谁赢了。
输入输出格式
输入格式
一行，a，b，n（1<=a,b,n<=100）
输出格式
一行，如果Simon赢了，输出0；Antisimon赢了，输出1.
说明
gcd(0,x)=gcd(x,0)=x;
对于样例1：
Simon拿gcd(3,9)=3颗
Antisimon拿gcd(5,6)=1颗
Simon拿gcd(3,5)=1颗
Antisimon拿gcd(5,4)=1颗
Simon拿gcd(3,3)=3颗
Antisimon输了
感谢@引领天下 提供的翻译
题目描述
Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number $ a $ and Antisimon receives number $ b $ . They also have a heap of $ n $ stones. The players take turns to make a move and Simon starts. During a move a player should take from the heap the number of stones equal to the greatest common divisor of the fixed number he has received and the number of stones left in the heap. A player loses when he cannot take the required number of stones (i. e. the heap has strictly less stones left than one needs to take).
Your task is to determine by the given $ a $ , $ b $ and $ n $ who wins the game.
输入输出格式
输入格式：The only string contains spaceseparated integers $ a $ , $ b $ and $ n $ ( $ 1<=a,b,n<=100 $ ) — the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile.
输出格式：If Simon wins, print "0" (without the quotes), otherwise print "1" (without the quotes).
输入输出样例
说明
The greatest common divisor of two nonnegative integers $ a $ and $ b $ is such maximum positive integer $ k $ , that $ a $ is divisible by $ k $ without remainder and similarly, $ b $ is divisible by $ k $ without remainder. Let $ gcd(a,b) $ represent the operation of calculating the greatest common divisor of numbers $ a $ and $ b $ . Specifically, $ gcd(x,0)=gcd(0,x)=x $ .
In the first sample the game will go like that:
 Simon should take $ gcd(3,9)=3 $ stones from the heap. After his move the heap has $ 6 $ stones left.
 Antisimon should take $ gcd(5,6)=1 $ stone from the heap. After his move the heap has $ 5 $ stones left.
 Simon should take $ gcd(3,5)=1 $ stone from the heap. After his move the heap has $ 4 $ stones left.
 Antisimon should take $ gcd(5,4)=1 $ stone from the heap. After his move the heap has $ 3 $ stones left.
 Simon should take $ gcd(3,3)=3 $ stones from the heap. After his move the heap has $ 0 $ stones left.
 Antisimon should take $ gcd(5,0)=5 $ stones from the heap. As $ 0<5 $ , it is impossible and Antisimon loses.
In the second sample each player during each move takes one stone from the heap. As $ n $ is even, Antisimon takes the last stone and Simon can't make a move after that.