All problems

Problem 963

Stone Game IV

Hard · 30 pts · Math, Dynamic Programming, Game Theory

Problem

There are N stones. Alice and Bob take turns, Alice first; on each turn a player removes a non-zero square number of stones (1, 4, 9, 16, ...). A player who cannot move loses. Both play optimally. Decide whether Alice wins. A position is winning if some square move leads to a losing position for the opponent, so fill win[0..N] from small to large, with win[0] = false.

Input

A single integer N.

Output

Print Alice if Alice wins, otherwise Bob.

Constraints

1 <= N <= 100000

Example input

1

Example output

Alice

Explanation

With 1 stone, Alice takes it and Bob cannot move, so Alice wins. With 2 stones, Alice must take 1, Bob takes the last one, and Bob wins.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Stone Game III Next: Number of Ways to Paint N × 3 Grid