#C11127. Sum and Product of Digits of Primes
Sum and Product of Digits of Primes
Sum and Product of Digits of Primes
You are given two integers \(n\) and \(m\) representing the boundaries of a range \([n, m]\) (inclusive). Your task is to:
- Find all prime numbers in the range \([n, m]\).
- Calculate the sum of these prime numbers.
- Concatenate all the prime numbers into a single number (in their natural order) and calculate the product of the digits in this concatenated number.
If there are no prime numbers in the range, output the sum as 0
and the product as 1
.
Note: A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
inputFormat
The input consists of a single line containing two space-separated integers \(n\) and \(m\) (with \(n \le m\)).
outputFormat
Output a single line with two space-separated integers: the sum of all prime numbers in the range and the product of the digits of these prime numbers (when concatenated). If no prime numbers exist in the range, output 0 1
.
10 20
60 189