printРабочее место участника

printЗадачи

2278. Quite prime numbers

Ограничения: время – 500ms/1000ms, память – 256MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

C-3PO doesn't like numbers, except for the primes, but preferably quite prime numbers. The number is called a quite prime number, if it is a prime number and sum of its digits is a quite prime number. For example, 31 isn't a quite prime, as the sum of its digits `3\ +\ 1\ =\ 4` isn't a prime, but 29 is a quite prime, as it is a prime, `2\ +\ 9\ =\ 11` is a prime and `1\ +\ 1\ =\ 2` is a prime.
Input
First line contains one integer `N` (`2\ ≤\ N\ ≤\ 10^{12}`).
Output
Program should print YES, if `N` is a quite prime, and NO otherwise.

Sample Input #1

31

Sample Output #1

NO

Sample Input #2

29

Sample Output #2

YES
loading