您好,欢迎来到化拓教育网。
搜索
您的当前位置:首页1015 Reversible Primes (20 分)-PAT甲级

1015 Reversible Primes (20 分)-PAT甲级

来源:化拓教育网

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

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuo9.cn 版权所有 赣ICP备2023008801号-1

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务