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 ...
随机推荐
- jQuery笔记(三)jQuery中的事件
; padding:0;} body { font-size:13px; line-height:130%; padding:60px;} #panel { width:300px; border:1 ...
- 【database】oracle集合 - Associative Arrays、Varrays、Nested Tables
前言 参考oracle官方文档:PL/SQL Language Reference 11g Release 2 - 5 PL/SQL Collections and Records 可以去看下文档 ...
- 【13】正则化网络激活函数(Batch归一化)
正则化网络激活函数(Batch归一化): 在神经网络训练中,只是对输入层数据进行归一化处理,却没有在中间层进行归一化处理.要知道,虽然我们对输入数据进行了归一化处理,但是输入数据经过σ(WX+b)σ( ...
- PP: Taking the human out of the loop: A review of bayesian optimization
Problem: Design problem parameters consist of the search space of your model. Scientists design expe ...
- 每天进步一点点------Modelsim添加Xilinx仿真库的详细步骤
Modelsim,可以选型SE和XE两个版本.Modelsim XE可以直接被ISE调用,而Modelsim SE需要手动添加仿真库.但SE版和OEM版在功能和性能方面有较大差别,比如对于大家都关心的 ...
- LeetCode 3sum-closest 题解
思路 排序 枚举一个数a 双指针移动法确定b和c 求和,更新最接近的值 复杂度 T(n)=O(n2)  M(n)=O(1)T(n)=O(n^2) \; M(n)=O(1)T ...
- Silver Cow Party POJ - 3268
#include<iostream> #include<queue> #include<cstring> using namespace std; +,INF=0x ...
- Coxeter积分计算
\begin{align*}&\int_0^{\frac{\pi}{3}}{\arccos \left( \frac{1-\cos x}{\text{2}\cos x} \right) dx} ...
- 在bootstrap的column中的formatter里不能传递row参数吗?
row 是一个对象 你需要把它转成字符串用JSON.stringify(row),这样就是字符串了,但是还有问题,你需要给加密一下encodeURI(JSON.stringify(row)),然后方 ...
- 任务调度问题(贪心) hdu4864
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4864 The company hopes to maximize the number of the t ...