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.
Input
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
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.
Example
Input: 3 2 1000 3 11 4 5 Output: 2 4 3
Constraints
0 < T < 512 1 < N < 10^8 1 < M < 10^9
For N, M : uniform random input in the range. One input file.
Information
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)
hide comments
wisfaq:
2015-01-18 21:30:24
I'm still curious what the 'intermediate' method is.
|
|
[Lakshman]:
2015-01-18 16:56:05
Yeh!! On the top. My method is faster for this but getting TLE in hard version.
|
|
[Lakshman]:
2015-01-18 15:46:00
Thanks @Francky I got Accepted with the Intermediate version now I will explore the the faster one.
|
|
abdou_93:
2015-01-18 15:26:29
I can't find any idea
|
|
[Lakshman]:
2015-01-18 14:32:28
@Francky I think I got the idea but wrong answer.
|
|
Francky:
2015-01-18 14:10:35
Congrats to wisfaq as the first solver.
|
|
ivar.raknahs:
2015-01-18 09:06:16
We need a good algorithm.Well very hard constraints.
|
|
[Lakshman]:
2015-01-17 16:33:11
@Francky can you please have a look at my algorithm, what is the expected complexity?
|
Added by: | Francky |
Date: | 2015-01-17 |
Time limit: | 5.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY |
Resource: | DIVFACT |