i think something is very wrong with this problem.

http://paste.ubuntu.com/23959438/ this is a AC code. but look at this two cases:

n=10 p=15

n=10 p=25

10!=1x2x3x4x5x6x7x8x9x10=2^8 x 3^3 x 5^2 x 7^1

that is divisible with 15^2 and 25^1

both cases this code gives 0

i think correct approach for this problem needs to generate prime number till 10^9 , that is feasible and does not match the problem constrain.

then factorize p(such p=p1.p2.p3...pm , where each of them is mutually coprime) and taking min of each of pi's power in n!