john_hopes's blog

By john_hopes, history, 7 months ago, In English,

Is there anyone can help me to solve this problem?

Problem Link:

Problem Description:

Alice and Bob take turns playing a game, with Alice going first. They begin with a pile of N stones, each turn removing one less than a prime number of stones. The person who removes the last stone wins. Given N, determine who wins the the game.

Constraints: N>0 and N<=10^9

I already read some solutions. They just pre calculated all the N for which Second Player wins and answer each query.

How can I pre calculate all the N(Second Player wins)?


7 months ago, # |
  Vote: I like it 0 Vote: I do not like it