Programmers and Stones
Time limit2sMemory limit2048 MB
Two players alternately pick any nonempty set of nonempty piles and remove one stone from each; determine the winner under optimal play.
- Level
Medium5 of 10
- Topics
- Game theory, Math
- Solved
- No attempts yet
Problem
Programmers Alice and Dmitry invented a new game. In this game, there are piles of stones on the table. The players take turns starting from Alice. On their turn, a player picks an arbitrary non-empty set of non-empty piles, and then removes one stone from each of them. The player who cannot make a move loses. Who will win the game if both play optimally?
Input
The first line contains an integer ().
The second line contains numbers : the initial sizes of the piles of stones ().
Output
Print "Alice" or "Dmitry", depending on who wins the game. Letter case does matter.