1015 Reversible Primes
1. 题目
2. 抽象建模
无
3. 方法
无
4. 注意点
- 素数判断(1不是素数)
- 数值的倒转
5. 代码
#include<stdio.h>
#include<math.h>
int isPrime(int num){
if(num < 2){
return 0;
}
for(int i=2;i<=num/2;i++){
if(num%i == 0){
return 0;
}
}
return 1;
}
int reverse(int num, int d, int &count){
if(num < d){
return num*pow(d, count++);
}else{
return reverse(num/d, d, count) + (num%d)*pow(d, count++);
}
}
int main(){
int order = 0;
int num, d;
while(1){
order = 0;
scanf("%d", &num);
if(num < 0){
break;
}
scanf("%d", &d);
if(isPrime(num) && isPrime(reverse(num, d, order))){
printf("Yes\n");
}else{
printf("No\n");
}
}
return 0;
}
1015 Reversible Primes的更多相关文章
- PAT 1015 Reversible Primes
1015 Reversible Primes (20 分) A reversible prime in any number system is a prime whose "rever ...
- PAT 甲级 1015 Reversible Primes(20)
1015 Reversible Primes(20 分) A reversible prime in any number system is a prime whose "reverse& ...
- PAT 1015 Reversible Primes[求d进制下的逆][简单]
1015 Reversible Primes (20)(20 分)提问 A reversible prime in any number system is a prime whose "r ...
- pat 1015 Reversible Primes(20 分)
1015 Reversible Primes(20 分) A reversible prime in any number system is a prime whose "reverse& ...
- PAT 甲级 1015 Reversible Primes (20 分) (进制转换和素数判断(错因为忘了=))
1015 Reversible Primes (20 分) A reversible prime in any number system is a prime whose "rever ...
- PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642
PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642 题目描述: A reversible prime in any n ...
- PTA (Advanced Level) 1015 Reversible Primes
Reversible Primes A reversible prime in any number system is a prime whose "reverse" in th ...
- 1015. Reversible Primes (20)
the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1015 this pro ...
- 1015 Reversible Primes (20)(20 point(s))
problem A reversible prime in any number system is a prime whose "reverse" in that number ...
- PAT 甲级 1015 Reversible Primes
https://pintia.cn/problem-sets/994805342720868352/problems/994805495863296000 A reversible prime in ...
随机推荐
- 关于c# hashtable的一个注意点
Hashtable在操作时,一定要注意一点: 当保存值时,如果使用的是字符串作为键,那么在判断是否存在此键时,必须使用字符串来检查,否则,即使是能隐式转换的值也将无法检查到,如: Hashtable ...
- idea插件不兼容问题
https://plugins.jetbrains.com/ 找对应版本的插件
- JavaScript-事件类型
DOM3事件类型: 1.UI事件:当用户与页面上的元素交互时触发 a.DOMActivate:元素已经被用户操作激活. b.load:(1)页面完全加载:window触发. (2)所有框架加载完毕:框 ...
- linux-redis cluster集群(redis5.x)
1.查看redis安装目录: [root@iZwz97y9qoykzzotubitq3Z redis-5.0.5]# lltotal 472-rw-rw-r-- 1 root root 106874 ...
- Numpy | ndarray数组基本操作
搞不懂博客园表格的排版... 说明: 0 ndarray :多维数组对象 1 np :import numpy as np 2 nda :表示数组的名称 1 生成数组 函数名 描述 np.array ...
- nginx配置长连接(ajax60秒请求超时)
个人博客 地址:http://www.wenhaofan.com/article/20180911150337 1.在使用ajax做轮训的时候前台发出的ajax请求总是会在60秒之后返回405超时响应 ...
- js报错 Uncaught TypeError: xxxx.each is not a function
在处理ajax返回的json数组时错误的使用了 list.each(function(){ }); 实际上当遍历json数组是应该使用 $.each(list,function(index,cours ...
- 01:认识QT
Qt: Qt是一个1991年由Qt Company开发的跨平台C++图形用户界面应用程序开发框架.它既可以开发GUI程序,也可用于开发非GUI程序,比如控制台工具和服务器.Qt是面向对象的框架,使用特 ...
- es6 新增变量声明方式
let 与 var var var声明的变量拥有全局作用域或者局部作用域 在全局中声明变量即为全局变量 在函数中声明变量即为局部变量 而var在使用过程中也逐渐暴露出许多问题 var的几大问题 变量提 ...
- BFC(块级格式化上下文)笔记
BFC特性: 1.BFC是一个独立的布局容器,内部元素不会影响BFC外面的元素,反之亦然. 2.计算BFC高度时,会计算内部的浮动元素. 3.BFC会阻止外边距的合并. 4.BFC的区域不会与外部浮动 ...