#K51772. Satisfaction Scores Based on Prime Factors
Satisfaction Scores Based on Prime Factors
Satisfaction Scores Based on Prime Factors
You are given a list of calorie counts. The satisfaction score for a given calorie count is defined as the number of distinct prime factors of that number. For example, the number 10 has two distinct prime factors (2 and 5), so its satisfaction score is 2.
Your task is to compute and output the satisfaction scores for each calorie count. Note that by definition, the number 1 has no prime factors, so its score is 0.
In mathematical terms, for a given integer \( n \), the satisfaction score is given by:
[ \text{satisfaction_score}(n) = #{ p : p \text{ is prime and } p \mid n } ]
Input: An integer \( n \) representing the number of calorie counts, followed by \( n \) integers denoting the calorie counts.
Output: A single line containing \( n \) integers separated by spaces, where each integer represents the satisfaction score for the corresponding calorie count.
inputFormat
The input is read from standard input (stdin) and has the following format:
T x1 x2 x3 ... xT
Here, T
is an integer representing the number of calorie counts, and x1, x2, ..., xT
are the calorie count values.
outputFormat
The output should be written to standard output (stdout) as a single line containing T
integers separated by spaces. Each integer is the satisfaction score (i.e., the number of distinct prime factors) corresponding to the calorie count.
4
10 15 21 23
2 2 2 1
</p>