Cups and Beans
Time limit1sMemory limit256 MB
Beans sit in cups 1 through N-1, each with a move limit C_i; players alternate sliding one bean to a lower cup and whoever cannot move loses. Decide the winner.
- Level
Hard8 of 10
- Topics
- Game theory, Dynamic programming, Combinatorics, Math
- Solved
- No attempts yet
Problem
There are cups numbered 0 through . For each (), cup contains beans, and this cup is labeled with an integer .
Two people play the following game:
- In each turn, the player chooses a bean from one of the cups except cup .
- If he chooses a bean from cup , he must move it to one of the cups .
- The players take turns alternately. If a player can't choose a bean, he loses.
Who wins if both players play optimally?
Input
Output
Print the name of the winner: "First" or "Second".
Constraints
- At least one of is nonzero.
- All values in the input are integers.
Hint
Notes on Sample 1:
- In the first turn, the first player must move a bean from to .
- In the second turn, the second player must move a bean from to .
- In the third turn, the first player can't choose a bean and loses.