DIVFACT2 - Divisors of factorial (medium)
Factorial numbers are getting big very soon, you'll have to compute the number of divisors of such highly composite numbers.
The first line contains an integer T, the number of test cases. On the next T lines, you will be given two integers N and M.
Output T lines, one for each test case, with the number of divisors of the factorial of N. Since the answer can get very big, output it modulo M.
Input: 3 2 1000 3 11 4 5 Output: 2 4 3
0 < T < 512 1 < N < 10^8 1 < M < 10^9
For N, M : uniform random input in the range. One input file.
Time limit is sqrt(T_good.py × T_bad.c). It implies that you can solve it with some interpreted languages with correct algorithm without any optis, but will get TLE with fast languages and non optimal algorithm. Good luck and have fun ;-)
(Edit 2017-02-11 : TL updated ; compiler changes)
Any hints for this problem ?? i give up
@francky can you plese provide some test case
I solved by precomputing all prime numbers less than 10^8 then determining no. of divisors but still getting TLE ....
not getting any idea how to solve this :( ...what other concepts are needed along with the lagrange's theorem..thanks in advance :)
Why this problem isn't showing on the list of solved problems? .. BTW awesome problem. Learnt a lot of things to optimize the code :)
Francky, would I get an AC if I precompute all the prime nos less than 10^8 then use (n)1/2(logn) per query?
Now there's DIVFACT4, it's time to move this one to tutorial, as almost every submission got AC with both (DF2, DF3) without any change.
@Francky my code works absolutely fine but still WA
Enjoying this!! Getting closer to abdou_93 Trying for first place..........Taken first place!!!
I'm still curious what the 'intermediate' method is.