Author: Vamsi Kavala
Tester: Roman Rubanenko
Editorialist: Bruno Oliveira
PROBLEM LINKS
DIFFICULTY
Cakewalk
PREREQUISITES
Simple Math, Integer Factorization
Problem:
You are given a very large number represented as a product of N numbers.
Given this number representation, you need to find the number of distinct factors of the original number which is formed by the product of given N numbers.
Quick Explanation:
We can factorize each one of the N given numbers into its prime factors. Then we find the number of occurrences of each prime factor, say they are a1, a2,ā¦aK, if we have K distinct prime factors. Our answer is simply: (a1+1)(a2+1)(ā¦)*(aK+1).
Detailed Explanation:
This problem relies on some knowledge of divisor function. Divisor functions returns the number of positive and distinct divisors of a number. Letās call it d(x).

Some properties of the divisor function:
We now look into some important properties of the divisor function:
For a prime number p, we have dĀ§ = 2, as there are only two numbers which divide a prime number:1 and itself.
Now, itās a known fact that this function is multiplicative but not completely multiplicative. This means that if two numbers, say, a and b are there such that gcd(a, b) = 1, then the following holds:
d(a*b) = d(a)*d(b).
This allows us to deduce the important relationship, that is the key of solving this problem:
For a prime number, p, we have: d(p^n) = n+1.
Now, itās easy to understand that all we need to do is to factorize all the N given numbers into its prime factors, and, for each prime factor we also need to count how many times it appears (that is, we need to know the exponent of each prime factor).
Once we have this count with us (which can be done using integer factorization and for example, the set and map data structures, one to guarantee uniqueness of the factors and the other to save the number of occurences for each unique prime factor), all we need to do is to multiply all these numbers plus one together and we will obtain our answer.
As an example, consider the number:
504 = 2^3 * 3^2 * 7^1
The number of distinct divisors of 504 is then (3+1) * (2+1) * (1+1) = 24.
Applying this process to all numbers yields the answer to the problem
SETTERāS SOLUTION
Can be found here.
TESTERāS SOLUTION
Testerās solution will be uploaded soon.
Useful Links
What is a multiplicative function?
More information on the divisor function