当前位置:网站首页>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;
}
边栏推荐
- Typescript indexable type
- [MySQL learning notes 29] trigger
- Typescript interface and the use of generics
- Project GFS data download
- js對象獲取屬性的方法(.和[]方式)
- Ble of Jerry [chapter]
- Cookie Technology & session Technology & ServletContext object
- [dictionary tree] [trie] p3879 [tjoi2010] reading comprehension
- Fundamentals of C language 9: Functions
- Select all the lines with a symbol in word and change them to titles
猜你喜欢
Solution to the problem of breakthrough in OWASP juice shop shooting range
NiO programming introduction
Twelve rules for naming variables
Markdown 中设置图片图注
杰理之如若需要大包发送,需要手机端修改 MTU【篇】
杰理之BLE【篇】
Sharing of source code anti disclosure scheme under burning scenario
The way to learn go (I) the basic introduction of go to the first HelloWorld
Crawling exercise: Notice of crawling Henan Agricultural University
JDBC学习笔记
随机推荐
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
Go learning -- implementing generics based on reflection and empty interfaces
leetcode704. Binary search (find an element, simple, different writing)
Ble of Jerry [chapter]
First knowledge of OpenGL es learning (1)
If Jerry's Bluetooth device wants to send data to the mobile phone, the mobile phone needs to open the notify channel first [article]
[dictionary tree] [trie] p3879 [tjoi2010] reading comprehension
Brief explanation of instagram operation tips in 2022
Methods for JS object to obtain attributes (. And [] methods)
ORACLE列转行--某字段按指定分隔符转多行
C - Inheritance - polymorphism - virtual function member (lower)
Simple and understandable high-precision addition in C language
Seriously recommend several machine learning official account
[MySQL learning notes 30] lock (non tutorial)
TS类型体操 之 字符串的妙用
OpenJudge NOI 2.1 1661:Bomb Game
Emo diary 1
Set picture annotation in markdown
烧录场景下的源代码防泄密方案分享
Relevant introduction of clip image