Find prime factorization of each number.
20 75 72 13
=>
(2^2 * 5^1) , (3^1*5^2) , (2^3*3^2) , (13^1)
Find max power of 2, max power of 3, max power of 5 and so on for each prime number.
=> LCM = 2^3 * 3^2 * 5^2 * 13^1
I donāt fully understand your approach.
What I did was,
find LCM of given N integers in form of its prime factors.
Let this LCM be k.
Then for each value in 1 to M (say i), find LCM(k,i)/k ( Basically find difference b/w powers of prime factors of i ). Output smallest index with highest value.
I have recently tried to solve the MXMLCM Problem from LTIME
here is the problem link
I have found something fishy with the test case for MXMLCM
hereās how
take this code
https://www.codechef.com/viewsolution/30842253
this code gets 100 points
while take my code
https://www.codechef.com/viewsolution/30842277
which gets wrong answer on 3 test cases and right on last test case
now run both the code with following input
1
6 9
1 9 4 4 1 4
my code gives 7
while the accepted useā¦
please see this it will clear your doubt