A8361 | Epic Game
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
Your task is to determine by the given $a$ , $b$ and $n$ who wins the game.
输入格式
The only string contains space-separated 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).
输入输出样例
输入 #1
3 5 9
输出 #1
0
输入 #2
1 1 100
输出 #2
1
The greatest common divisor of two non-negative 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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted