Nim Take Stones
EasyMathGame Theory
Description
Two players play optimally. A pile has n stones. On each turn a player removes between 1 and k stones inclusive. The player who removes the last stone wins. Return true if the first player wins.
Examples
Input:
n = 4, k = 3Output:
falseExplanation:
Whatever first player takes, second can take to leave a multiple of 4 again, eventually forcing first to lose.
Input:
n = 5, k = 3Output:
trueExplanation:
First takes 1 to leave 4, then mirrors.
Input:
n = 1, k = 1Output:
trueExplanation:
First player takes the only stone.
Constraints
- •
1 ≤ n ≤ 10⁹ - •
1 ≤ k ≤ 100