Preparando MOJI

Truncatable primes

3000ms 262144K

Description:

A truncatable prime is a prime number which contains no zeros in decimal notation and all its suffixes are primes. 1 is considered to be not a prime.

You are given a positive integer n. Figure out whether it is a truncatable prime.

Input:

The only line of input contains an integer n (2 ≤ n ≤ 107).

Output:

Output "YES" if n is a truncatable prime. Output "NO" otherwise. Quotes for clarity only.

Sample Input:

19

Sample Output:

NO

Sample Input:

9137

Sample Output:

YES

Note:

In the first sample 19 is a prime but its suffix 9 is not.

In the second sample 9137, 137, 37 and 7 are all primes, so 9137 is a truncatable prime.

Informação

Codeforces

Provedor Codeforces

Código CF162I

Tags

*special

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 08:35:12

Relacionados

Nada ainda