Untitled
unknown
plain_text
2 years ago
470 B
5
Indexable
//Bai 3
#include <iostream>
#include <cmath>
using namespace std;
int nt(int n){
for(int i = 2; i <= sqrt(n); i++){
if(n%i == 0) return 0;
}
return n > 1;
}
int rev(int n){
int tmp = 0;
while(n){
tmp = tmp*10 + n%10;
n /= 10;
}
return tmp;
}
int main(){
freopen("CPRIME.inp","r",stdin);
freopen("CPRIME.out","w",stdout);
int n; cin >> n;
if(nt(n) && nt(rev(n))) cout << 1 << endl;
else cout << 0 << endl;
return 0;
}Editor is loading...
Leave a Comment