PAT (Advanced Level)1015. Reversible Primes (20)
2018-02-27 21:36
477 查看
题目链接
//1015. Reversible Primes(20) #include <iostream> #include <cstring> #include <cmath> using namespace std; int PimeJudge(int a) { if (a < 2) return 0; if (a == 2 || a == 3) return 1; for (int i = 2; i*i <= a; i++) { if (a%i == 0) return 0; } return 1; } int main() { int a, b; while (cin >> a) { if (a < 0) return 0; cin >> b; int c[15]; int aa = a; int sub = 0; while (a != 0) { c[sub++] = a % b; a /= b; } int realinD = 0; for (int i = 0; i < sub; i++) { realinD += (c[i])*pow(b, sub - i - 1); } if (PimeJudge(aa) && PimeJudge(realinD)) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
相关文章推荐
- 【c++】PAT (Advanced Level)1015. Reversible Primes (20)
- 【PAT Advanced Level】1015. Reversible Primes (20)
- 【PAT Advanced Level】1015. Reversible Primes (20)
- PAT (Advanced Level) Practise 1015. Reversible Primes (20) 素数筛法 进制转换
- 1015. Reversible Primes (20) ——PAT (Advanced Level) Practise
- 【PAT】【Advanced Level】1015. Reversible Primes (20)
- 1015. Reversible Primes (20) ——PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise 1015. Reversible Primes (20)
- PAT (Advanced Level) 1015. Reversible Primes (20)
- PAT (Advanced Level) 1015. Reversible Primes (20) 翻转质数
- 浙大 PAT Advanced level 1015. Reversible Primes (20)
- PAT (Advanced Level) Practise 1015. Reversible Primes (20)
- PAT (Advanced Level)1023. Have Fun with Numbers (20)
- 【PAT】【Advanced Level】1058. A+B in Hogwarts (20)
- 【C++】PAT(advanced level)1061. Dating (20)
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- PAT (Advanced Level) Practise 1120 Friend Numbers (20)
- 【PAT】【Advanced Level】1092. To Buy or Not to Buy (20)
- 1061. Dating (20)【字符串操作】——PAT (Advanced Level) Practise
- 【PAT】【Advanced Level】1112. Stucked Keyboard (20)