1015. Reversible Primes (20)
2024-08-31 06:09:28
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");
}
}
最新文章
- php开发总结
- rel=";stylesheet"; 描述
- 64位Ubuntu 13.04 安装Bochs 2.3.5
- 为什么只有在用Visual Studio启动程序时会抛出InvalidOperationException异常
- C# 获取word批注信息
- ALV 数值列负号前置 (EDIT_MASK应用)
- C语言 - 大小端问题
- oracle常用函数及关键字笔记
- RxSwift 系列(二) -- Subject
- MP4大文件虚拟HLS分片技术,避免服务器大量文件碎片
- centos7 nginx安装/启动/进程状态/杀掉进程
- Junit概述
- C++ 字面量
- JAVA文件操作类和文件夹的操作代码示例
- call与apply简单介绍
- 基于alpine用dockerfile创建的tomcat镜像
- Spring MVC - MultipartFile实现文件上传(单文件与多文件上传)
- Android-Broadcast(广播)
- 《图解Http》8: 用户身份认证Cookie管理session; 9:HTTP的追加协议(websoket, webDAV)
- 摘:用ADO操作数据库的方法步骤
热门文章
- vc编译器 msvcr.dll、msvcp.dll的含义和相关错误的处理
- iOS数据存储之属性列表理解
- 使用 gradle 编译多版本 android 应用
- hive 安装教程
- 十字链表 Codeforces Round #367 E Working routine
- Navicat 远程连接SQL Server 2014 Express 报08001错误
- java工程师的标准
- 第二百六十七天 how can I 坚持
- 软件工程个人作业——Agile Software Development读后感
- hdu 3038 How Many Answers Are Wrong