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 ...
随机推荐
- Vue(三)--循环语句
v-for: v-for 指令需要以 site in sites 形式的特殊语法, sites 是源数据数组并且 site 是数组元素迭代的别名. demo1. <!DOCTYPE html&g ...
- Django-模型(二)
条件查询 字段查询 实现sql中where的功能,调用过滤器filter().exclude().get(),下面以filter()为例. 通过"属性名_id"表示外键对应对象的i ...
- 0级搭建类002-Oracle Linux 8.x安装(OEL 8.0) 公开
项目文档引子系列是根据项目原型,制作的测试实验文档,目的是为了提升项目过程中的实际动手能力,打造精品文档AskScuti. 项目文档引子系列目前不对外发布,仅作为博客记录.如学员在实际工作过程中需提前 ...
- Word报表生成
/// <summary> /// 生产报表 /// </summary> /// <param name="strTemplate">< ...
- Mysql分库分表导出导入和数据量统计测试
需求:添加创建了分库分表后,业务可能将数据已经写入,但未来得及接入到otter汇总库.接入汇总库前需要初始化这部分数据. 1.导出 ip_port_list ) len=${#ip_port_list ...
- php中的require和include区别
require是无条件包含也就是如果一个流程里加入require,无论条件成立与否都会先执行require 1.require 的使用方法如 require("MyRequireFile.p ...
- 性能优化-css,js的加载与执行
前端性能优化 css,js的加载与执行 javascript是单线程的 一个网站在浏览器是如何进行渲染的呢? html页面加载渲染的过程 html渲染过程的一些特点 顺序执行,并发加载 词法分析 并发 ...
- XSS漏洞的poc与exp
poc <script>alert('xss')</script> 最简单常用的poc <a href='' onclick=alert('xss')>type& ...
- npm命令笔记-----转自网络,仅供自己查看使用
npm是一个node包管理和分发工具,已经成为了非官方的发布node模块(包)的标准.有了npm,可以很快的找到特定服务要使用的包,进行下载.安装以及管理已经安装 的包. npm常用指令 1.npm ...
- Qtree3 - 树链剖分
打完以后才发现写复杂了……算了懒得改了 #include <bits/stdc++.h> using namespace std; ],fa[][],size[],wson[],vis[] ...