PAT 2019-3 7-1 Sexy Primes】的更多相关文章

Description: Sexy primes are pairs of primes of the form (p, p+6), so-named since "sex" is the Latin word for "six". (Quoted from http://mathworld.wolfram.com/SexyPrimes.html) Now given an integer, you are supposed to tell if it is a s…
算是第二次做这套题吧,感觉从上次考试到现在自己有了挺大提高,提前30min做完了. 7-1 Sexy Primes 读懂题意就行. #include <cstdio> #include <iostream> #include <cmath> #include <algorithm> #include <vector> using namespace std; bool isPrime(int n) { ) return false; int tm…
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…
考试的还行.不过略微有点遗憾,但是没想到第一题会直接上排序和dfs,感觉这次的题目难度好像是倒着的一样.哈哈哈哈. 第一题实在是搞崩心态,这道题给我的感觉是,可以做,但事实上总是差点啥. 第二题,第三题,把我的心态稳住了,不然的话这次考试可能会雪崩.这两道题目都是提交一次,直接全红. 接着二三题带来的信心把第四题搞定了,好像提交了两次. 然后就又开始死磕第一题,关键是当时自己以为第一题不应该用dfs,就一直在修改细节.╮(╯▽╰)╭,还是超时. 感觉PAT不算很难,但是在新的环境.计时.排队提交…
先判断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…
转换进制&&逆序可以在一起进行,有一点技巧,不要用十进制数来表示低进制,容易溢出. #include <iostream> #include <vector> using namespace std; bool isPrime(int n) { if(n < 2) return false; if(n == 2) return true; if(n % 2 == 0) return false; for(int i = 3; i < n; i += 2)…
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 (&…
Sexy primes are pairs of primes of the form (p, p+6), so-named since “sex” is the Latin word for “six”. (Quoted from http://mathworld.wolfram.com/SexyPrimes.html) Now given an integer, you are supposed to tell if it is a sexy prime. Input Specificati…
7-1 Sexy Primes 判断素数 一个点没过17/20分 错因:输出i-6写成了输出i,当时写的很乱,可以参考其他人的写法 #include<bits/stdc++.h> using namespace std; const int maxn = 1e8; typedef long long ll; int n; bool isprime(ll x){ if(x == 0 || x==1 || x==2) return false; for(ll i=2;i<=sqrt(x);i…
转自https://blog.csdn.net/weixin_40688413/article/details/88082779 担心别人删除了就找不到了.因为九月要考. 7-1 Sexy Primes (20 分)Sexy primes are pairs of primes of the form (p, p+6), so-named since “sex” is the Latin word for “six”. (Quoted from http://mathworld.wolfram.…