Dangerous Divisor
Submit solution
Points:
1
Time limit:
1.5s
Memory limit:
256M
Problem type
Allowed languages
C, C++, Java, Python
Jamie and Marcus are playing a game to determine who gets a free ACPC T-Shirt. Ritisha has provided them an integer , and they repeatedly take turns altering the number according to certain rules. The player who is unable to move loses (i.e. when
is
).
On a given turn, the player must:
- Chose a proper divisor
of
, i.e.
- Replace
with
Surprisingly, both Jamie and Marcus are playing the game optimally. Jamie always goes first, and Marcus second. For a given , determine if Jamie or Marcus will win.
Input
A single integer (
)
Output
Output the person who will win if both play optimally and the person who is unable to move loses (i.e. when ). Jamie goes first and Marcus goes second.
Example
Input 1
5
Output 1
Marcus
- First, Jamie must subtract
as it is the only proper divisor:
- Next, Marcus can either subtract
or
. If he subtracts,
, Jamie will subtract
and win, so Marcus subtracts
.
.
- Jamie can only subtract
.
.
- Marcus subtracts
. Now
so Jamie has no option and Marcus wins.
Input 2
1
Output 2
Marcus
Jamie instantly loses. Classic Jamie.
Input 3
10
Output 2
Jamie
There are a number of ways the game can go but Jamie can always force a win.
Comments