#P5635. Modular Sum Game Outcome
Modular Sum Game Outcome
Modular Sum Game Outcome
In this game, two players, cbw and zhouwc, start with two integers \(x\) and \(y\) respectively, and a modulus \(p\). The game is played in rounds as follows:
- Round 1: Update \(x \leftarrow (x+y) \bmod p\).
- Round 2: Update \(y \leftarrow (x+y) \bmod p\).
- Round 3: Update \(x \leftarrow (x+y) \bmod p\).
- Round 4: Update \(y \leftarrow (x+y) \bmod p\).
- And so on...
The game terminates when either of the following happens:
- If \(x\) becomes \(0\) (first), then
cbw
wins. - If \(y\) becomes \(0\) (first), then
zhouwc
wins. - If both numbers never become \(0\) (i.e. the process loops without hitting zero), the game is declared a
draw
.
</p>
Your task is to simulate the game and determine the outcome.
inputFormat
The input consists of three space-separated integers: \(x\), \(y\) and \(p\).
\(x\) and \(y\) represent the initial numbers held by cbw
and zhouwc
respectively, and \(p\) is the modulus.
outputFormat
Output a single line containing one of the strings cbw
, zhouwc
, or draw
depending on the outcome of the game.
sample
1 1 10
cbw