mirror of
https://github.com/xlucn/PAT.git
synced 2026-10-28 18:41:38 +08:00
28 lines
992 B
HTML
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 (< 10<sup>5</sup>) and D (1 < D <= 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> |