#K82942. Distinct Prime Factor Count
Distinct Prime Factor Count
Distinct Prime Factor Count
You are given an integer (M) and an array (B) of (M) integers. Your task is to compute the number of distinct prime factors of the product (P) where (P = \prod_{i=1}^{M} B_i). In other words, if (P) is factorized into its prime factors as (P = p_1^{\alpha_1} \times p_2^{\alpha_2} \times\cdots\times p_k^{\alpha_k}), then your answer should be (k).
Note: When an element of the array is 1, it does not contribute any prime factors.
Example:
For (M = 3) and (B = [2, 3, 5]), we have (P = 2 \times 3 \times 5 = 30). The prime factors of 30 are (2, 3,) and (5). Hence, the output is 3.
inputFormat
The first line contains an integer (M) — the number of elements in the array. The second line contains (M) space-separated integers representing the array (B).
outputFormat
Output a single integer that denotes the number of distinct prime factors of the product of all elements in the array.## sample
3
2 3 5
3
</p>