当前位置:网站首页>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;
}
边栏推荐
- OpenJudge NOI 2.1 1749:数字方格
- How Navicat imports MySQL scripts
- [MySQL learning notes 29] trigger
- Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
- TypeScript 函数定义
- 软件测试界的三无简历,企业拿什么来招聘你,石沉大海的简历
- Detailed explanation | detailed explanation of internal mechanism of industrial robot
- Scala语言学习-08-抽象类
- 位运算异或
- Word delete the contents in brackets
猜你喜欢

Three no resumes in the software testing industry. What does the enterprise use to recruit you? Shichendahai's resume

jmeter性能测试步骤实战教程

杰理之如若需要大包发送,需要手机端修改 MTU【篇】

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

1091: two or three things in childhood (multi instance test)

Go learning --- use reflection to judge whether the value is valid

Force buckle day31

Relevant introduction of clip image
![If Jerry needs to send a large package, he needs to modify the MTU on the mobile terminal [article]](/img/57/12a97ab3d2dabfaf06bbe1788450cf.png)
If Jerry needs to send a large package, he needs to modify the MTU on the mobile terminal [article]

Excel的相关操作
随机推荐
If Jerry needs to send a large package, he needs to modify the MTU on the mobile terminal [article]
Jerry needs to modify the profile definition of GATT [chapter]
ORACLE列转行--某字段按指定分隔符转多行
How are the open source Netease cloud music API projects implemented?
SSM learning
TypeScript 接口属性
Mise en œuvre du langage leecode - C - 15. Somme des trois chiffres - - - - - idées à améliorer
杰理之如若需要大包发送,需要手机端修改 MTU【篇】
【mysql学习笔记29】触发器
When the Jericho development board is powered on, you can open the NRF app with your mobile phone [article]
Méthode d'obtention des propriétés de l'objet JS (.Et [] méthodes)
[online problem processing] how to kill the corresponding process when the MySQL table deadlock is caused by the code
Introduction to the basics of network security
GET/POST/PUT/PATCH/DELETE含义
jmeter性能测试步骤实战教程
TypeScript接口与泛型的使用
Brief explanation of instagram operation tips in 2022
js對象獲取屬性的方法(.和[]方式)
LeetCode Algorithm 2181. Merge nodes between zero
剪映的相关介绍