#include
#include
#include
#include
using namespace std;
long long generatePalindrome(long long num) {
string strNum = to_string(num);
string reversedStr = strNum;
reverse(reversedStr.begin(), reversedStr.end());
strNum.pop_back();
strNum += reversedStr;
return stoll(strNum);
}
bool isprime(long long x){
if (x <= 1) return false;
if (x == 2) return true;
if (x % 2 == 0) return false;
for (long long i = 3; i <= sqrt(x); i += 2) {
if (x % i == 0) return false;
}
return true;
}
int main(){
long long t;cin>>t;
long long x = generatePalindrome(t);
if(isprime(x)){cout<<"prime"<
#include
#include
#include
using namespace std;
long long generatePalindrome(long long num) {
string strNum = to_string(num);
string reversedStr = strNum;
reverse(reversedStr.begin(), reversedStr.end());
strNum.pop_back();
strNum += reversedStr;
return stoll(strNum);
}
bool isprime(long long x){
if (x <= 1) return false;
if (x == 2) return true;
if (x % 2 == 0) return false;
for (long long i = 3; i <= sqrt(x); i += 2) {
if (x % i == 0) return false;
}
return true;
}
int main(){
long long t;cin>>t;
long long x = generatePalindrome(t);
if(isprime(x)){cout<<"prime"<
全部评论
相关推荐
点赞 评论 收藏
分享