Files
PAT/html/a1015.html
T

28 lines
992 B
HTML

<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h1>1015. Reversible Primes (20)</h1>
<div id="problemContent">
<p>A <i>reversible prime</i> in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a prime.
</p>
<p>Now given any two positive integers N (&lt; 10<sup>5</sup>) and D (1 &lt; D &lt;= 10), you are supposed to tell if N is a reversible prime with radix D.
<p><b>
Input Specification:
</b></p>
<p>The input file consists of several test cases. Each case occupies a line which contains two integers N and D. The input is finished by a negative N.</p>
<p><b>
Output Specification:
</b></p>
<p>For each test case, print in one line "Yes" if N is a reversible prime with radix D, or "No" if not.</p>
<b>Sample Input:</b><pre>
73 10
23 2
23 10
-2
</pre>
<b>Sample Output:</b><pre>
Yes
Yes
No
</pre>
</p></div>