FACTMULO  Product of factorials (again)
For n positive integer, let F(n) = 1! × 2! × 3! × 4! × ... × n!, product of factorial(i) for i in [1..n],
For p a prime number, and n an integer,
and let V(p, n) = max({i>=0 integer, such that p^i divides F(n)}).
Input
The first line of input contains an integer
T, the number of test cases.
On each of the next T lines, your are given
two integers p a prime number, and n.
Output
For each test case, you have to print V(p, n).
Example
Input: 2 2 3 3 4
Output: 2 2
Constraints
0 < T < 10^5 1 < p < 10^18, a prime number 0 < n < 10^18
p and n are loguniform independent randomly distributed.
Four lines of Python code can get AC in half the time limit. (Edit 20170211, after compiler changes)
;) Have fun.
hide comments
hodobox:
20170503 00:08:12
Reminder to C++ users: __int128 is now a thing :) 

[Rampage] Blue.Mary:
20160113 07:08:15
PIKE is so slow while processing input/output data...


varun bumb:
20150723 23:42:07
Finally AC!! really nice problem :)


Sayak Haldar:
20150717 20:41:48
Got a wrong answer...then understand that answer would not fit a 64 bit container..this problem is a little difficult for c and c++ users I guess Last edit: 20150717 20:45:47 

Rishav Goyal:
20150710 13:38:46
stupid solution. so much float on shit. 

sameer Hussain:
20150629 14:27:22
Thanks Francky :), 

sameer Hussain:
20150627 13:16:25
@francky, I am getting WA many a times,


scyth3r:
20150626 08:35:50
piece of cake...just i needed was patience :p


:.Mohib.::
20150625 20:50:55
AC after lot of WA.... :)


Curiosa:
20150312 04:10:50
@Francky I am getting WA, but I think I am on the right track and cannot find out my mistake.

Added by:  Francky 
Date:  20140301 
Time limit:  1.5s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Own problem 