Loading [MathJax]/extensions/TeX/mathchoice.js

Problem #282

Game Time

Let a_{i+1}=(c*a_{i} + d) \mod m where c=5447196, d=1953840 and m=998244353 be a pseudo random number generator for 0 \leq i \leq N-3 where N=100000 and a_0=a_{N-1}=a_{N}=0

One day, Taniya created a game in which there were N blocks arranged sequentially. A player starts at the 1st block. To go from the ith block to the (i+1)th block, the player has to take a jump. The jump will succeed with probability p, meaning that the player will go to the (i+1)th block with probability p,otherwise he will have to start from the beginning and will be landed at the 1st block. The game ends when the player reaches the Nth block. Further, there is a penalty of a_i coins each time a player lands on block i. Taniya was not sure what value to pick for p and so she randomly selected a number from [0.5\ ,\ 1]. Calculate the Expected number of coins a player has to pay before the game ends.

It can be shown that the answer can be expressed as \frac{p}{q}, where \gcd(p,q) = 1 and q \neq 0 \mod m. Output pq^{-1} \mod m.

Contributed by Aryan Bidani

Solved by 8 users

Log in to submit answers.

Is something wrong?

Maintaining a collection of high quality questions is our top priority. If, however, you do find an error, report the problem and we'll make sure it is reviewed soon.