#K58467. Twisted Primes
Twisted Primes
Twisted Primes
In this problem, you are given two integers L and R where L ≤ R. Your task is to find all the Twisted Primes in the inclusive range [L, R]. A number p is defined as a Twisted Prime if:
- p is a prime number.
- If you reverse the digits of p to obtain a number r, then r is also a prime number.
- The reversed number r is different from p (i.e. p is not a palindromic prime).
If there is no twisted prime in the range, output -1.
For example:
Input: 10 100 Output: 13 17 31 37 71 73 79 97
Note that numbers are output in increasing order and separated by a single space.
inputFormat
The input consists of a single line containing two integers L and R (with L ≤ R) separated by a space.
outputFormat
Output all twisted primes in the range [L, R] in ascending order, separated by a single space. If there are no twisted primes, output -1.## sample
10 100
13 17 31 37 71 73 79 97
</p>