PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000060. Trò chơi Euclid (Euclid’s Game)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Trò chơi Euclid (Euclid’s Game)
Euclid's Game
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Stan and Ollie take turns playing with two positive integers, with Stan moving first. On a turn, a player subtracts a positive integer multiple of one value from the other value, keeping the result nonnegative. Equal values are allowed: a player can then subtract one value from the other to obtain zero. Whoever makes a value zero wins immediately. Both players play optimally. Print the winner.
Input
Two positive integers a and b.
Output
Exactly Stan wins or Ollie wins.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
34 12
Output
Stan wins
Explanation
Stan subtracts from , leaving . Ollie has only one legal move: subtract from , leaving . Stan then subtracts from to create and win, so the output is Stan wins.