## fractal161's Qualifier

Player:

Event:

Tournament:

Status:

Approved

Score 1:

1,398,740

Score 2:

1,095,740

Total score:

1,247,240

Details:

Let p be an odd prime number less than 10^5. Granite and Pomegranate play a game. First, Granite picks a integer c from the set {2,3,...,p-1}.
Pomegranate then picks two integers d and x, defines f(t) = ct + d, and writes x on a sheet of paper.
Next, Granite writes f(x) on the paper, Pomegranate writes f(f(x)), Granite writes f(f(f(x))), and so on, with the players taking turns writing.
The game ends when two numbers appear on the paper whose difference is a multiple of p, and the player who wrote the most recent number wins. Find the sum of all p for which Pomegranate has a winning strategy.