先判断n是否为素数然后把n转化成d进制下再反转,转化为十进制的num判断num是否为素数 注意n为0和1时,不是素数!!!注意反转后的num也有可能为1,不是素数!!! #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; int n,d; bool isprime(in…
PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642 题目描述: 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…
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789189.html特别不喜欢那些随便转载别人的原创文章又不给出链接的所以不准偷偷复制博主的博客噢~~ 水题,找出哪个数只出现过一次,输出那个数如果没有的话,输出None #include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g…
#include <iostream> #include <cstdio> #include <string.h> #include <algorithm> using namespace std; /* 水题,注意字符范围是整个ASCII编码即可. */ ; int vis[maxn]; +]; +]; int main() { gets(s1); //getchar(); gets(s2); int len1=strlen(s1); int len2=s…
输入为两个分数,让你计算+,-,*,\四种结果,并且输出对应的式子,分数要按带分数的格式k a/b输出如果为负数,则带分数两边要有括号如果除数为0,则式子中的结果输出Inf模拟题最好自己动手实现,考验细节处理,其它没啥好说的. #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; ]; ]; long long GC…
题意:一个正整数n可以分解成一系列因子的乘积,其中会存在连续的因子相乘,如630=3*5*6*7,5*6*7即为连续的因子.给定n,让你求最大的连续因子个数,并且输出其中最小的连续序列. 比如一个数可以分解2*3*4*6*7*8,最大的连续个数为3,因为存在两个,输出最小的那个即2*3*4. 首先,一个数如果是合数,那么它的因子必定不会超过sqrt(n)或者sqrt(n)+1.如果为质数,那么只可能为自己,因为题目说了不包括1. 我们先将2~sqrt(n)+1中为n的因子存到factor数组中,…
求给出数的平均数,当然有些是不符合格式的,要输出该数不是合法的. 这里我写了函数来判断是否符合题目要求的数字,有点麻烦. #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> using namespace std; ; bool islegal(char*str){ int len=strlen(str); ,; ;i<len;i++){ //if…
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789775.html特别不喜欢那些随便转载别人的原创文章又不给出链接的所以不准偷偷复制博主的博客噢~~ 水题,就是统计n个数的数位和有多少个不同的,并且输出即可. #include <iostream> #include <cstdio> #include <algorithm> #include <string> #in…
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 prime. Now given any two positive integers N (&…
题目 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 prime. Now given any two positive integers N…