#C13974. Prime Group Sum
Prime Group Sum
Prime Group Sum
You are given a single integer n
as input. Your task is to compute the sum of the first n
prime numbers after they have been grouped by the number of digits they have. More precisely, you should:
- Generate the first
n
prime numbers. - Group these primes based on the number of digits (for instance, 1-digit primes, 2-digit primes, etc.).
- For each group, calculate the sum of the primes in that group.
- Output the sum of all these group sums.
Note: If n
is zero, the output should be 0.
Example:
Input: 10 Output: 129</p>Explanation: The first 10 primes are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. They form the groups: Group 1 (1-digit): 2+3+5+7 = 17 Group 2 (2-digit): 11+13+17+19 = 60 Group 3 (2-digit): 23+29 = 52 Total sum: 17 + 60 + 52 = 129
inputFormat
The input is read from standard input (stdin) and consists of a single integer n
, which indicates the number of prime numbers to be considered.
outputFormat
Output a single integer to standard output (stdout) which is the sum of the sums of the prime groups.
## sample10
129