the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1015

this problem is relatively easy.if there must be something which need to be noticed, i think

“1 is not a prime” could be one of them.

#include<stdio.h>

bool isPrime(int n)
{
if (n == 1)
{
return false;
}
if (n == 2)
return true;
else
{
for (int i = 2; i < n; i++)
{
if (n % i == 0)
{
return false;
}
}
return true;
}
} int main()
{
int n,d;
while (scanf("%d",&n))
{
if (n < 0)
break;
scanf("%d",&d);
int temp = n;
int count = 0;
while (n/d != 0)
{
count += n%d;
count *= d;
n /= d;
}
count += n%d;
if (isPrime(temp)&&isPrime(count))
{
printf("Yes\n");
}
else
printf("No\n");
}
}

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

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

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

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

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

  3. PAT 1015 Reversible Primes (20分) 谜一般的题目,不就是个进制转换+素数判断

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

  4. 1015 Reversible Primes (20)(20 point(s))

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

  5. 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 ...

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

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

  7. 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<cstring> #include<cmath> #include<algorithm> ...

  9. PAT甲题题解-1015. Reversible Primes (20)-素数

    先判断n是否为素数然后把n转化成d进制下再反转,转化为十进制的num判断num是否为素数 注意n为0和1时,不是素数!!!注意反转后的num也有可能为1,不是素数!!! #include <io ...

随机推荐

  1. An Oblivious Watermarking for 3-D Polygonal Meshes Using Distribution of Vertex Norms

    An Oblivious Watermarking for 3-D Polygonal Meshes Using Distribution of Vertex Norms 转眼就11月底了,突然开始有 ...

  2. 学习笔记之Linux内核编译过程

    准备工作 物理主机:win8(32位) 虚拟机工具:VirtualBox_4.3.16_Win32 虚拟主机:xubuntu-12.04.4 安装virtualBox功能增强包 设置好虚拟机与主机的共 ...

  3. 修改linux主机名称

    linux修改主机名如下操作即可: [root@kel ~]# cat /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=no HOSTNAM ...

  4. CentOS下编译安装hping3

    安装hping之前,先装上libpcap-dev和tcl-dev 1.获取源码包 wget http://www.hping.org/hping3-20051105.tar.gz 2.解压,得到 hp ...

  5. Linux内存中的Cache真的能被回收么?

    在Linux系统中,我们经常用free命令来查看系统内存的使用状态.在一个RHEL6的系统上,free命令的显示内容大概是这样一个状态: [root@tencent64 ~]# free       ...

  6. [现代程序设计]homework-03

    Homework-03 队员: 11061193 薛亚杰 11061192 周敏轩    11061190 李孟 材料阅读 我们三个人将以下材料仔细阅读,觉得十分受益.下面是我们的总结和分享: 1)代 ...

  7. ocp 1Z0-042 1-60题解析

    1. Because of a power outage,instance failure has occurred. From what point in the redo log does rec ...

  8. HDU 3416 Marriage Match IV (求最短路的条数,最大流)

    Marriage Match IV 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/Q Description Do not si ...

  9. codeforces300A Array

    A. Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  10. [C语言 - 6] static & extern

    A. extern函数 一个c文件生成一个obj文件   外部函数:允许其他文件访问.调用的函数(默认函数为外部函数),不允许存在同名的外部函数   my.c //define a extern fu ...