当前位置:网站首页>1015 reversible primes (20 points) prime d-ary
1015 reversible primes (20 points) prime d-ary
2022-07-06 07:27:00 【Python ml】
#include <iostream>
using namespace std;
bool isprime(int a){
if(a==1)return false;
for(int i=2;i*i<=a;i++)
if(a%i==0)return false;
return true;
}
int main() {
int n,d;
while (scanf("%d",&n)!=EOF){
if(n<0)break;
scanf("%d",&d);
if(isprime(n)==false){
printf("No\n");
continue;
}
int len=0,arr[100];
do{
// Convert to d Base number
arr[len++]=n%d;
n=n/d;
}while(n>0);
for(int i=0;i<len;i++) // Calculation d The corresponding 10 Whether the hexadecimal number is a prime number
n=n*d+arr[i];
printf("%s\n", isprime(n) ? "Yes" : "No");
}
return 0;
}
边栏推荐
- Sharing of source code anti disclosure scheme under burning scenario
- Markdown 中设置图片图注
- Uni app practical project
- 烧录场景下的源代码防泄密方案分享
- Brief explanation of instagram operation tips in 2022
- Emo diary 1
- leetcode704. Binary search (find an element, simple, different writing)
- 【线上问题处理】因代码造成mysql表死锁的问题,如何杀掉对应的进程
- 学go之路(二)基本类型及变量、常量
- 杰理之BLE【篇】
猜你喜欢
Oracle database 11gr2 uses TDE transparent data encryption to report an error ora28353. If you run to close the wallet, you will report an error ora28365. If you run to open the wallet, you will repor
Fundamentals of C language 9: Functions
When the Jericho development board is powered on, you can open the NRF app with your mobile phone [article]
qt颜色与字符串、uint相互转换
【线上问题处理】因代码造成mysql表死锁的问题,如何杀掉对应的进程
Significance and measures of encryption protection for intelligent terminal equipment
【MySQL学习笔记32】mvcc
The way to learn go (I) the basic introduction of go to the first HelloWorld
(4) Web security | penetration testing | network security web site source code and related analysis
leecode-C語言實現-15. 三數之和------思路待改進版
随机推荐
How are the open source Netease cloud music API projects implemented?
qt颜色与字符串、uint相互转换
TypeScript 函数定义
leecode-C语言实现-15. 三数之和------思路待改进版
Bit operation XOR
Methods for JS object to obtain attributes (. And [] methods)
How MySQL merges data
Excel的相关操作
Full Score composition generator: living on code
The way to learn go (II) basic types, variables and constants
Emo diary 1
【MySQL学习笔记32】mvcc
word中把带有某个符号的行全部选中,更改为标题
杰理之BLE【篇】
[MySQL learning notes 32] mvcc
【mysql学习笔记29】触发器
Summary of Digital IC design written examination questions (I)
Word delete the contents in brackets
OpenJudge NOI 2.1 1661:Bomb Game
navicat如何导入MySQL脚本