SMALLM  Smallest Number (medium)
60 is divisible by 2, 3, 4 and 5. No smaller number than 60 have this property.
Input
On the first line, you will be given two integers
T (the number of test cases), and
M (an integer).
Each of the next T lines contains an integer N.
Output
For each test case, output on one line, the smallest number that is divisible
by all integers from 1 to N (inclusive).
As the answer may be a big number, output it modulo M.
Example
Input: 1 1000000007 5 Output: 60
Constraints
T <= 10^5 10^8 <= M <= 2×10^9, a prime number 0 < N < 10^8
Information
There's one easy input file, and several harder ones. Time limit allows unoptimized code with fast languages to get AC ; for slower languages it may be hard.
Good luck and have fun ;)
Edit(20170211) : New time limit (after compiler changes).
hide comments
aj_254:
20190519 21:00:53
@nadstratosfer role mode for me :) python master 

nadstratosfer:
20190519 19:27:15
I've had 999 problems and this wasn't one of them.. until now! Actually, I've prototyped this in Python 2 days ago (would need TL ~ 11s to AC in PyPy :/) but held back with implementing in C for this special occasion. Great problem but I'll have to revisit once I finally get the core routine needed here out of my todoinC list.


Bhuvnesh Jain:
20161102 12:10:50
@Francky, any hints on how I can further speedup my solution (Submission ID : 18083628)? Last edit: 20161102 12:13:05 

ashish kumar:
20151225 12:22:35
How can I fast up my code it gives AC on 11 sec. Any suggestion. 

:.Mohib.::
20150723 12:02:00
Last edit: 20150723 12:40:01 

Sayak Haldar:
20150715 04:21:56
Francky,could you please do me another favour? Could you please tell me what is the actual result fro N=100 and M=1000000007. I tried normal modulo based calculation (multiplication) as well as modular arithmetic related multiplication method depicted in wikipedia. Now, I am uncertain which one is the actual result for N=100 and M=1000000007


Sayak Haldar:
20150714 22:12:28
Francky: could you please check my solution with solution id 14669671? Does it contain too many WAs? also, does this solution generate TLE for any particular case?


Sayak Haldar:
20150306 13:48:12
Francky, what is the needed time complexity for this problem?


dark king :
20150225 19:05:47
1 second is approx. how many operations? 

Adarsh kumar:
20150224 21:46:48
Same code passes for SMALL ... but here gives WA ... unable to figure out :(

Added by:  Francky 
Date:  20150124 
Time limit:  0.5s2s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 JSMONKEY 
Resource:  SMALL 