Subtask1-2 : Find the LCM, And see if LCM is divisible by ci or not. It can be seen that the LCM fits in 64-bit integer.

Subtask 3 : As the LCM won't fit in 64-bit integer. FInd the LCM as Prime factorization of the LCM. After that, For each prime divisor of c, answer will be the minimum of freqLCM(p)/freqC(p), where freqLCM(p) means frequency of prime p in the LCM and freqC(p) means frequency of prime p in c.

Subtask 4-5. It is not possible to loop through all the numbers and find LCM as prime factorization in this case. So, to find freqLCM(p) we can just see if there is any number that is divisible by pi. This can be done is log() complexity and as the number of different primes won't exceed 15 we can easily find freqLCM(p). In subtask 4 freqC(p) can be easily done in sqrt(c) complexity. But In subtask 5 it won't work. You can use Pollard's rho algorithm to prime factorize c.

Statistics

29% Solution Ratio
riyad000Earliest, Jul '20
Ahasan_1999Fastest, 0.0s
riyad000Lightest, 131 kB
bokaifShortest, 664B
Toph uses cookies. By continuing you agree to our Cookie Policy.