Multiplication Game
InterviewTime limit1sMemory limit128 MB
Alice and Bob multiply a running product by 2 to 9 in turn; find who forces the product to reach n first with optimal play.
- Level
Medium5 of 10
- Topics
- Game theory, Dynamic programming, Math
- Solved
- No attempts yet
Problem
Alice and Bob play a multiplication game. An integer starts at , and beforehand a fixed integer with is chosen.
On each turn, the player to move multiplies by one integer between and inclusive. Alice moves first, then Bob, and they keep alternating turns.
The player who first makes wins.
Assuming both players play optimally, write a program that determines the winner.
Input
The input consists of several test cases. Each test case is a single line containing the integer . Process every test case until the end of input.
Output
For each test case, print Alice wins. if Alice wins, or Bob wins. if Bob wins, one per line.