#K46822. Count Distinct Prime Factors

    ID: 28062 Type: Default 1000ms 256MiB

Count Distinct Prime Factors

Count Distinct Prime Factors

Given an integer \(n\), the goal is to count the number of distinct prime factors of \(n\). A prime factor of \(n\) is a prime number that divides \(n\) without leaving a remainder.

You are required to implement a function count_distinct_prime_factors(n) that returns the number of distinct prime factors of \(n\). In addition, implement a test case processor that reads multiple test cases, applies the function, and prints the results.

The detailed mathematical background: if \(n\) is factorized as \(n = p_1^{a_1} \times p_2^{a_2} \times \cdots \times p_k^{a_k}\), where \(p_i\) are distinct prime numbers, the answer should be \(k\). Note that if \(n < 2\), i.e. \(n = 1\), the number of distinct prime factors is 0.

inputFormat

The input is read from standard input and consists of multiple test cases. The first line contains an integer \(T\) indicating the number of test cases. Each of the following \(T\) lines contains a single integer \(n\) (\(1 \leq n \leq 10^{12}\)).

outputFormat

For each test case, output a line containing a single integer representing the number of distinct prime factors of \(n\), printed to standard output.

## sample
5
10
15
21
28
99792
2

2 2 2 4

</p>