Time Limit

How can I lower my time limit for this question :-

Its time limit is 1 second and my program run for 1.04200 seconds .

Please Help

please refer to this editorial.the main idea is to factorize each number into prime factors and keep a count of the occurence of each factor.This is a root(N) algorithm while you are using a O(N) algorithm. You could do this with a hashmap or even array.the final answer can be found as given in the editorial.

1 Like