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. LoadRunner检查点实战

    码农博客 即将到期,现将博客中部分文章转载到博客园.转载时略有删减. 一.为什么要使用检查点 为什么要使用检查点,那就要说明一下LR如何判断脚本是否执行成功. LR判断脚本是否执行成功是根据服务器返回 ...

  2. CATALOGUE 目录

    1 语言基础 1.1 c/c++ [转]C/C++ 存储类型 作用域 连接类型 [转]C/C++内存划分 [转]C/C++除法实现方式及负数取模详解 [转]为什么C++编译器不能支持对模板的分离式编译 ...

  3. asp.net MVC 安全性[笔记]

    1. 跨站脚本(XSS) 1.1 介绍 1.1.1 被动注入,利用输入html,javascript 等信息伪造链接,图片等使用提交信息,调转页面等 1.1.2 主动注入,黑客主动参与攻击,不会傻等倒 ...

  4. lsof,nc

    安装nc, yum -y install nc; 用nc传输同步文件 A,被同步端-即需要备份复制端; tar -czvf - /|nc 192.168.1.204(同步机ip,复制文件位置机) 88 ...

  5. BAT-使用BAT生成快捷方式

    @( echo [InternetShortcut] echo URL=C:\Windows\System32\calc.exe echo IconIndex=0 echo IconFile=C:\W ...

  6. 轻松学习 red5 教程 像视频一样很详细还有代码直接可Copy

    转载自:http://blog.csdn.net/hongdianking/archive/2009/11/12/4804339.aspx 最近要做一个流媒体服务器,在网上逗留了好久决定选择 red5 ...

  7. ocp 1Z0-051 71-105题解析

    71. Which arithmeticoperations can be performed on a column by using a SQL function that is builtint ...

  8. socket的shutdown与close

    shutdown原型 int shutdown(int socket, int how); socket 指定socket的文件描述符 how    指定shutdown的类型 SHUT_RD 禁止读 ...

  9. C#操作Excel的OLEDB方式与COM方式比较

    2013-03-15 13:42:54      作者:有理想的码农   在对Excel进行读写操作时,使用微软自身提供的解决方案,有两种(第三方方式除外),分别是OLEDB方式和调用COM组件的方式 ...

  10. npm package 装包匹配原则

    经常看到package.json 里面有这样的devDependencies: "devDependencies": { "@angular/common": ...