Problem Link : http://www.codechef.com/problems/NUMFACT
Need an Efficient Solution !
1 Like

make a function to check if numbers are prime (isPrime()).

divide the given number (in this case the product) by all primes less than that number and find out how many times it repeats for that number.

result = (a1+1).(a2+2)…(ak+1) where ai(1<=i<=k) are counts of all primes below the number.
improvise this for the program. this is just a hint. happy coding !
Yeah Buddy Thanx . But the solution you are giving surely gives TLE. Bdw you check count of max.number of times a prime divisors appears for each individual number of array and then it will give correct answer.
1 Like