#K68827. Prime Concatenation
Prime Concatenation
Prime Concatenation
You are given a list of prime numbers. Your task is to determine if there exist two distinct primes \(p_i\) and \(p_j\) in the list such that, when you concatenate their decimal representations, the resulting number is also a prime number.
For example, when the list is [3, 7], concatenating 3 and 7 forms 37, which is prime, so the answer is YES. If no such pair exists, output NO.
Note: The concatenation of two numbers \(a\) and \(b\) is the number formed by writing the digits of \(a\) followed immediately by the digits of \(b\). For instance, concatenating 11 and 13 results in 1113.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer \(n\) representing the number of prime numbers.
- The second line contains \(n\) space-separated integers, each representing a prime number from the list.
outputFormat
Output a single line to standard output (stdout) containing either YES
if there exists a pair of distinct primes whose concatenation forms a new prime number, or NO
otherwise.
4
2 3 5 11
YES