# 1015. Reversible Primes (20)-PAT甲级真题

A reversible prime 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.

Now given any two positive integers N (< 105) and D (1 < D <= 10), you are supposed to tell if N is a reversible prime with radix D.

Input Specification:

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.

Output Specification:

For each test case, print in one line “Yes” if N is a reversible prime with radix D, or “No” if not.

Sample Input:
73 10
23 2
23 10
-2
Sample Output:
Yes
Yes
No

❤ 点击这里 -> 订阅《PAT | 蓝桥 | LeetCode学习路径 & 刷题经验》by 柳婼

❤ 点击这里 -> 订阅《从放弃C语言到使用C++刷算法的简明教程》by 柳婼

❤ 点击这里 -> 订阅PAT甲级乙级、蓝桥杯、GPLT天梯赛、LeetCode题解离线版
{"ft_lang_label":"__label__en","ft_lang_prob":0.5573593,"math_prob":0.784836,"size":1510,"snap":"2023-14-2023-23","text_gpt3_token_len":618,"char_repetition_ratio":0.09296149,"word_repetition_ratio":0.027118644,"special_character_ratio":0.38741723,"punctuation_ratio":0.13392857,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9618799,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-04-01T21:14:45Z\",\"WARC-Record-ID\":\"<urn:uuid:c815ae3a-19d2-400a-9c3e-6fcdcb93b4c5>\",\"Content-Length\":\"57585\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:74ffeb82-72d3-4e16-aee0-856d4ce2dd81>\",\"WARC-Concurrent-To\":\"<urn:uuid:ffded7c6-df56-4265-acbe-e60c0c02984b>\",\"WARC-IP-Address\":\"116.62.117.169\",\"WARC-Target-URI\":\"https://www.liuchuo.net/archives/2149\",\"WARC-Payload-Digest\":\"sha1:TOHEQRGSRVODUMPDEUVR5K6SVF3YB7YP\",\"WARC-Block-Digest\":\"sha1:KHOGA3KVQNCZM3H4IDXLQACINS5IMMVT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296950247.65_warc_CC-MAIN-20230401191131-20230401221131-00210.warc.gz\"}"}