300853: CF162I. Truncatable primes
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
I. Truncatable primestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
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.
InputThe only line of input contains an integer n (2 ≤ n ≤ 107).
OutputOutput "YES" if n is a truncatable prime. Output "NO" otherwise. Quotes for clarity only.
ExamplesInput19Output
NOInput
9137Output
YESNote
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.