//1015. Reversible Primes (20)
//acc
#include <iostream>
using namespace std;
int Prime( int x )
{
int i;
if(x==1)
return 0;
for (i =2;i<=x/2;i++)
{
if (x%i == 0)
{
return 0;
}
}
return 1;
}
int main()
{
int N, D;
int a[15];
bool flag = true;
int i = 0;
int len;
int rn;
while((cin>>N)!=NULL)
{
if (N <0 )
{
break;
}
cin>>D;
if (!(Prime(N)))
{
cout<<"No\n";
}
else
{
//计算多进制的值
i = 0;
while(N!=0)
{
a[i++] = N%D;
N = N/D;
}
len = i;
rn = 0;
for(i=0;i<len-1;i++)
{
rn+= a[i];
rn*=D;
}
rn += a[i];
if(Prime(rn))
{
cout<<"Yes\n";
continue;
}
else
{
cout<<"No\n";
continue;
}
}
}
return 0;
}
相关推荐
RAGFlow + GraphRAG+ 知识图谱 + QwQ32B探索实践
RagFlow 是一款开源的 RAG(Retrieval-Augmented Generation)引擎,专注于深度文档理解,能够助力企业及个人构建高效的 RAG 工作流程。借助大语言模型(LLM),它可以精准处理各种复杂格式的数据,为用户提供可靠的问答服务,并附上详实的引用依据。
PAT甲级 1015 Reversible Primes (20分)
PAT甲级 1015 Reversible Primes (20分) 做好本题的首要是读懂题意,然后就是注意坑点,本题最后一个测试点即为坑点,因为int型最大的数转成2进制或者1进制肯定是会超越int的表示范围,故答案出错误。其余3个点为常规测试点。 附本人暴力代码,讲真不建议刷PAT直接对照着别人的代码敲一遍,那样提升会很小,自己实在做不出来再参考别人的,本人这题做了挺长时间的,但是还是自己AC了。100行左右的代码! #include <iostream> #include <cstd
避坑指南:海康MV_CC_SetIntValue接口的7个典型报错解决方案
本文深度解析海康工业相机SDK中MV_CC_SetIntValue接口的典型报错,提供7个实战解决方案。针对MV_E_CALLORDER、MV_E_PARAMETER等高频错误码,从设备状态、参数值域、依赖关系等核心约束入手,给出清晰的诊断流程与根治代码,帮助开发者构建健壮的参数设置模块,提升开发效率。
【PAT甲级】1015 Reversible Primes (20 分)
1015 Reversible Primes 题目描述 A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because...
Matlab实战:用DQN算法让机器人学会自主避障(附完整代码)
本文详细介绍了如何使用Matlab实现DQN(深度Q网络)算法,使机器人在复杂环境中学会自主避障。通过环境建模、网络架构设计、奖励函数优化及实战调试,提供了完整的代码实现和训练策略,帮助开发者快速应用于机器人路径规划项目。
【时时三省】tessy 单元测试 之 CTE(The Classification Tree Editor) 的使用
有图有文字详细介绍利用 CTE界面中的树 批量产生用例。
PAT甲级 - 1015 Reversible Primes (20 分)
题目链接:PAT甲级 - 1015 Reversible Primes (20 分) A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversib...
PCL 基于强度的双边滤波【2026最新版】
基于强度信息的双边滤波代码实现、滤波前后点云未出现变化的原因以及获取带有强度pcd点云的方法。本文由优快云点云侠原创,博客长期更新,本文最近一次更新时间为:2026年5月24日。
PAT-1015 Reversible Primes (20)
题目大意:每组测试中给出一个十进制数 N 和进制 D,求 N 化为 D 进制的逆序是否为质数和 N 是否是质数。解题思路:简单题。题目链接:https://www.patest.cn/contests/pat-a-practise/1015#include <iostream> #include <algorithm> #include &l...
复现报告:《多回路人机控制系统仿真及II型PIO分析》方法复现与代码实现
本文复现了谭文倩硕士论文《多回路人机控制系统仿真及II型PIO分析》中的关键方法,重点实现了频域驾驶员模型辨识和参数灵敏度分析。通过数字化提取论文图表数据,构建了结构驾驶员模型传递函数,并验证了参数变化对系统特性的影响。采用MATLAB实现了描述函数计算、模型参数辨识和灵敏度分析算法,为后续神经网络模型辨识和II型PIO研究奠定了基础。由于缺乏原始实验数据,部分结果通过数值模拟获得,但仍有效重现了论文的核心分析方法。~~~~~
FTU电科院检测学习笔记-规划
如果写到最后,还非常的有动力和兴趣,可能会举出一些特定的例子来,但不保证一定是这样。
[PAT] 1015 Reversible Primes (20 分)Java
A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also...
文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况
主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。
pat 1015 Reversible Primes(20 分)
1015 Reversible Primes(20 分) A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible ...
华为的C语言编程规范.pdf
华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。
蓝牙模块HM-10手册
蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。
PAT甲级-1015 Reversible Primes (20分)
点击链接PAT甲级-AC全解汇总 题目: A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its re...
数学建模模型总结
这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!
PAT:A1015 Reversible Primes (20 分)
PAT:A1015 Reversible Primes (20 分) A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime...
【PAT甲级】1015 Reversible Primes (20分)
解题过程的小记录,如有错误欢迎指出。 难度:三星(求素数的模板+进制转换模板) 小导航~题目分析我的解题过程思路bug代码dalao的代码借鉴点 题目分析 给出一个十进制下的数和另外一个进制,如果这个十进制下的数是素数,当它用另外一个进制进行转换后反转然后再次转化为十进制依旧是素数的话,则输出Yes,反之输出No 我的解题过程 思路 写一个判断是否是素数的函数,为了节省时间用sqrt 首先判断初始给出的十进制数是否是素数,如果不是就没有必要进行后续的步骤 将十进制数按给定的进制求余,并且同时将原结果*进制
PAT甲级1015. Reversible Primes (20)
A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a pri
PAT甲级 1015 Reversible Primes (20 分)
题意: 给定一个十进制下的数n,然后在d进制下反转得到一个数 如果这两个数都是素数Yes,,否则No 思路: 如上 #include<bits/stdc++.h> #define FI first #define SE second using namespace std; typedef long long ll; const ll maxn = 1e8 + 7;...
PAT1015 Reversible Primes (20 分)
1015 Reversible Primes (20 分) A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime becau...
1015. Reversible Primes (20)-PAT
1015. Reversible Primes (20) A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime b
PAT 1015 Reversible Primes (20)
1015. Reversible Primes (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A reversible prime in any number system
PAT A1015 Reversible Primes (20)
PTA跳转:原题链接 题是简单题,难点在于读题。 题目大意:判断一个数和它转换成N进制后进行翻转再转换成10进制的数是否都是素数,如果是,输出“Yes”,否则输出“No”。 例如“23 2”,23是素数,23转换成2进制后是10111,翻转后是11101,转换成10进制后是29,29也是素数,所以输出“Yes”。 #include <iostream> #include <math.h> using namespace std; int isPrime(int n) //判断素数
PAT A 甲级 1015 Reversible Primes (20分)
1015 Reversible Primes (20分) 吐槽 说实话做之前我真不确定0和1是不是质数。 以及这道题居然是“以负数输入为结束”而不是一贯的先给个说明之后要输入几次的n!这一点都不PAT! 思路 没啥好说的。一个判断是不是质数的函数、一个进制转化的部分,都是基础操作。 唯一要特别注意的是1和0不是质数。(测点1) 而且这句特判必须写在判断的函数里,而不是直接判断输入的n是不是0或1,...
8万+



被折叠的 条评论
为什么被折叠?



