#K65497. Prime Permutation
Prime Permutation
Prime Permutation
Given an integer (n), determine whether any permutation of its digits forms a prime number. A permutation of (n) is obtained by rearranging its digits, possibly leading to numbers with leading zeros. If at least one permutation is a prime number, print YES
; otherwise, print NO
.
A number (p) is prime if it is greater than 1 and has no positive divisors other than 1 and itself. For example, (2), (3), and (13) are primes, while (1), (4), and (6) are not.
You can assume that the number of digits in (n) is small enough to allow checking all permutations within the time limits.
inputFormat
The input contains a single line with the integer (n). The integer may include leading zeros when considered as a permutation but is provided as a usual number string.
outputFormat
Output a single line containing YES
if at least one permutation of the digits of (n) forms a prime number; otherwise, output NO
.## sample
197
YES