#C11641. Distinct Prime Factors of Array Sum
Distinct Prime Factors of Array Sum
Distinct Prime Factors of Array Sum
Given an array of N integers, calculate the sum of all the elements. If the sum is a prime number, output 1. Otherwise, output the number of distinct prime factors of the sum. The factors should be considered only once regardless of their multiplicity.
For example:
- For an array
[2, 4, 7]
withN=3
, the sum is 13 which is prime, so the output is1
. - For an array
[10]
withN=1
, the sum is 10 and its distinct prime factors are 2 and 5, so the output is2
.
Your task is to implement a solution that reads the input from standard input and writes the output to standard output.
inputFormat
The first line of input consists of a single integer N
, the number of array elements.
The second line contains N
space-separated integers representing the elements of the array.
outputFormat
Output a single integer which is either 1 if the sum of the array is prime, or the number of distinct prime factors of the sum if it is composite.
## sample3
2 4 7
1
</p>