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");
}
}

最新文章

  1. php开发总结
  2. rel=&quot;stylesheet&quot; 描述
  3. 64位Ubuntu 13.04 安装Bochs 2.3.5
  4. 为什么只有在用Visual Studio启动程序时会抛出InvalidOperationException异常
  5. C# 获取word批注信息
  6. ALV 数值列负号前置 (EDIT_MASK应用)
  7. C语言 - 大小端问题
  8. oracle常用函数及关键字笔记
  9. RxSwift 系列(二) -- Subject
  10. MP4大文件虚拟HLS分片技术,避免服务器大量文件碎片
  11. centos7 nginx安装/启动/进程状态/杀掉进程
  12. Junit概述
  13. C++ 字面量
  14. JAVA文件操作类和文件夹的操作代码示例
  15. call与apply简单介绍
  16. 基于alpine用dockerfile创建的tomcat镜像
  17. Spring MVC - MultipartFile实现文件上传(单文件与多文件上传)
  18. Android-Broadcast(广播)
  19. 《图解Http》8: 用户身份认证Cookie管理session; 9:HTTP的追加协议(websoket, webDAV)
  20. 摘:用ADO操作数据库的方法步骤

热门文章

  1. vc编译器 msvcr.dll、msvcp.dll的含义和相关错误的处理
  2. iOS数据存储之属性列表理解
  3. 使用 gradle 编译多版本 android 应用
  4. hive 安装教程
  5. 十字链表 Codeforces Round #367 E Working routine
  6. Navicat 远程连接SQL Server 2014 Express 报08001错误
  7. java工程师的标准
  8. 第二百六十七天 how can I 坚持
  9. 软件工程个人作业——Agile Software Development读后感
  10. hdu 3038 How Many Answers Are Wrong