当前位置:网站首页>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;
}
边栏推荐
- mysql如何合并数据
- word中把帶有某個符號的行全部選中,更改為標題
- [dictionary tree] [trie] p3879 [tjoi2010] reading comprehension
- Typescript indexable type
- Supervisor usage document
- 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
- Project GFS data download
- Méthode d'obtention des propriétés de l'objet JS (.Et [] méthodes)
- Bloom taxonomy
- 杰理之蓝牙设备想要发送数据给手机,需要手机先打开 notify 通道【篇】
猜你喜欢

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

数字IC设计笔试题汇总(一)

Redis builds clusters

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

leecode-C语言实现-15. 三数之和------思路待改进版

Excel的相关操作

Related operations of Excel

leetcode704. Binary search (find an element, simple, different writing)

Detailed explanation | detailed explanation of internal mechanism of industrial robot

You deserve this high-value open-source third-party Netease cloud music player
随机推荐
【MySQL学习笔记32】mvcc
Select all the lines with a symbol in word and change them to titles
Crawling exercise: Notice of crawling Henan Agricultural University
leetcode704. Binary search (find an element, simple, different writing)
Jerry's ad series MIDI function description [chapter]
Scala language learning-08-abstract classes
洛谷P1836 数页码 题解
[MySQL learning notes 32] mvcc
Typescript function definition
Typescript interface and the use of generics
If Jerry's Bluetooth device wants to send data to the mobile phone, the mobile phone needs to open the notify channel first [article]
Project GFS data download
SSM learning
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Excel的相关操作
学go之路(二)基本类型及变量、常量
学go之路(一)go的基本介绍到第一个helloworld
OpenJudge NOI 2.1 1661:Bomb Game
Typescript void base type