当前位置:网站首页>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;
}
边栏推荐
- 超级浏览器是指纹浏览器吗?怎样选择一款好的超级浏览器?
- Detailed explanation | detailed explanation of internal mechanism of industrial robot
- 智能终端设备加密防护的意义和措施
- 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
- 成为优秀的TS体操高手 之 TS 类型体操前置知识储备
- 杰理之需要修改 gatt 的 profile 定义【篇】
- navicat如何导入MySQL脚本
- [dictionary tree] [trie] p3879 [tjoi2010] reading comprehension
- Significance and measures of encryption protection for intelligent terminal equipment
- How MySQL merges data
猜你喜欢

Do you really think binary search is easy

Fundamentals of C language 9: Functions

leecode-C语言实现-15. 三数之和------思路待改进版
![Ble of Jerry [chapter]](/img/ed/32a5d045af8876d7b420ae9058534f.png)
Ble of Jerry [chapter]

Seriously recommend several machine learning official account

Mise en œuvre du langage leecode - C - 15. Somme des trois chiffres - - - - - idées à améliorer

JDBC learning notes

Markdown 中设置图片图注

JMeter performance test steps practical tutorial

Set picture annotation in markdown
随机推荐
洛谷P4127 [AHOI2009]同类分布 题解
杰理之开发板上电开机,就可以手机打开 NRF 的 APP【篇】
(4) Web security | penetration testing | network security web site source code and related analysis
How to configure GUI guide development environment
chrome查看页面fps
Week6 weekly report
OpenJudge NOI 2.1 1661:Bomb Game
可变参数重载时的内存错误
[MySQL learning notes 32] mvcc
ORACLE列转行--某字段按指定分隔符转多行
How to delete all the words before or after a symbol in word
OpenJudge NOI 2.1 1661:Bomb Game
Ble of Jerry [chapter]
GET/POST/PUT/PATCH/DELETE含义
洛谷P1836 数页码 题解
If Jerry's Bluetooth device wants to send data to the mobile phone, the mobile phone needs to open the notify channel first [article]
成为优秀的TS体操高手 之 TS 类型体操前置知识储备
[MySQL learning notes 29] trigger
js对象获取属性的方法(.和[]方式)
Crawling exercise: Notice of crawling Henan Agricultural University