-->
当前位置:首页 > 题库

PROGRAMMING:Invertible prime numbers in arbitrary system

Luz5年前 (2021-05-10)题库447
The reversible prime number in any system is defined as follows: it is a prime number. When it is converted to any system, all the numbers are reversed, and the value of the new number is still a prime number. For example, 73 is a prime in the decimal system, and its inverse 37 is also a prime in the decimal system, so it is called a reversible prime in the decimal system.
###Input format:
The input has multiple lines, each line includes two positive integers, the number N and the base R, where n < 100000, 1 < d < = 10, and exits when a negative number is encountered.
###Output format:
For each line input, if it is a reversible prime, output "yes", otherwise output "no"
###Input example:
Here is a set of inputs. For example:
```in
73 10
23 2
23 10
-2
```
###Output example:
The corresponding output is given here. For example:
```out
Yes
Yes
No
```
Example: 23 binary is 10111, its inverse is 11101, the corresponding decimal number is 29, so it is a reversible prime< br>





answer:If there is no answer, please comment