We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

It says P X Q(-1) mod (10^9 + 7), which makes very little sense as sample output is just single number, e.g. if I try 1.0000 instead - it will be wrong. Plus as number of cells is restricted to 40 x 40, final result will never be over 1600; which makes mod statement somehow reflecting precision of result.

Can somebody clearify output format?

It says P X Q(-1) mod (10^9 + 7), which makes very little sense as sample output is just single number, e.g. if I try 1.0000 instead - it will be wrong. Plus as number of cells is restricted to 40 x 40, final result will never be over 1600; which makes mod statement somehow reflecting precision of result.

Please, help.

For output a/b, does it want a*b mod (10^9 + 7)? It says Q^(-1) which is confusing because ab^(-1) = a/b.

Dynamic Programming times out. Must be a better way.

Markov Chains ?Adjacent squares are squares that share an edge.

Why are there at most fleas per cell in the sample?