题解 | #素数回文#
素数回文
https://www.nowcoder.com/practice/d638855898fb4d22bc0ae9314fed956f
#include <iostream> #include <cmath> using namespace std; bool ss(long long num){ if(num < 2){ return false; } for(long long i = 2; i <= sqrt(num); i++){ if(num % i == 0){ return false; } } return true; } int main() { long long t; cin>>t; if(ss(t)){ string t1 = to_string(t); string t2 = t1; for(int i=0;i<t1.length();i++){ t2[i]=t1[t1.length()-2-i]; } string tt = t1+t2; if(ss(stoll(tt))){ cout<<"prime"; }else{ cout<<"noprime"; } } }