简单题。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
using namespace std; int a,b;
int h[],tot; bool f(int x)
{
if(x==) return ;
for(int i=;i*i<=x;i++) if(x%i==) return ;
return ;
} int main()
{
while(~scanf("%d",&a))
{
if(a<) break; scanf("%d",&b);
if(f(a)==) printf("No\n");
else if(a==) printf("No\n");
else
{
int tmp=a; tot=;
while(tmp) h[tot++]=tmp%b,tmp=tmp/b;
int num=;
for(int i=;i<tot;i++)
num=num+h[i]*(int)pow(b,tot-i-);
if(f(num)==) printf("Yes\n");
else printf("No\n");
}
}
return ;
}

PAT (Advanced Level) 1015. Reversible Primes (20)的更多相关文章

  1. PTA (Advanced Level) 1015 Reversible Primes

    Reversible Primes A reversible prime in any number system is a prime whose "reverse" in th ...

  2. 【PAT甲级】1015 Reversible Primes (20 分)

    题意: 每次输入两个正整数N,D直到N是负数停止输入(N<1e5,1<D<=10),如果N是一个素数并且将N转化为D进制后逆转再转化为十进制后依然是个素数的话输出Yes,否则输出No ...

  3. PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642 题目描述: A reversible prime in any n ...

  4. PAT 甲级 1015 Reversible Primes (20 分) (进制转换和素数判断(错因为忘了=))

    1015 Reversible Primes (20 分)   A reversible prime in any number system is a prime whose "rever ...

  5. PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...

  6. PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...

  7. PAT (Advanced Level) Practice 1015 Reversible Primes (20 分)

    A reversible prime in any number system is a prime whose "reverse" in that number system i ...

  8. 【PAT Advanced Level】1015. Reversible Primes (20)

    转换进制&&逆序可以在一起进行,有一点技巧,不要用十进制数来表示低进制,容易溢出. #include <iostream> #include <vector> ...

  9. PAT Advanced 1015 Reversible Primes (20) [素数]

    题目 A reversible prime in any number system is a prime whose "reverse" in that number syste ...

随机推荐

  1. 初识Iaas,paas

    Iaas(Infrastructure-as-a-service),直译为基础设备作为一种服务. Paas(Platform as a service),直译为平台作为一种服务. 暂且忘掉这两个单词, ...

  2. 取distinct数据同时还取其他字段

    的 SELECT id,group_concat(distinct model) FROM tsdr_case group by model order by id

  3. Q_DISABLE_COPY

    QObject 中没有提供一个拷贝构造函数和赋值操作符给外界使用,其实拷贝构造和赋值的操作都是已经声明了的,但是它们被使用了Q_DISABLE_COPY() 宏放在了private区域.因此所有继承自 ...

  4. u盘烧写后实际容量变小了

    百度了一下 : http://jingyan.baidu.com/article/d45ad148f383ea69552b808a.html 百度下载 USBoot 打开软件 列表中选择你的U盘,点击 ...

  5. 【servlet】 过滤器模板

    EncodingFilter.java package Filter; import java.io.IOException; import javax.servlet.Filter; import ...

  6. Filter 解决web网页跳转乱码

    为什么采用filter实现了字符集的统一编码 问题: 为什么会有字符集编码的问题呢?对于Java Web应用,使用Tomcat容器获取和传递的参数(request.getParameter())默认是 ...

  7. 解决编译时出现的警告:format string is not a string literal (potentially insecure)

    NSLog([NSString stringWithFormat:@"%@/%@B.jpg", createDir, uuid]);//这是我的写法 应该写成 NSString * ...

  8. checking for known struct flock definition... configure: error: Don't know how to define struct flock on this system, set --enable-opcache=

    在对php进行安装的过程中出现如下错误: 1.报错信息: 1 checking for known struct flock definition... configure: error: Don't ...

  9. UIScreen的scale属性

    用来表示显示屏的像素密度与点坐标系统之间的关系.通过该属性,我们可以把视图中逻辑坐标系统里的点坐标转换成设备的物理像素坐标.在配有Retina显示屏的设备中,scale值是2.0,而在非Retina显 ...

  10. MySQL操作失误导致mysql数据库查看不了

    使用  show databases; +--------------------+| Database           |+--------------------+| information_ ...