Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- using namespace std;
- int rever(int n){
- int a = 0;
- while(n){
- a *= 10;
- int k = n % 10;
- a += k;
- n /= 10;
- }
- return a;
- }
- bool prime(int a){
- for(int i = 2; i <= sqrt(a); i++){
- if(!(a % i)) return false;
- }
- return true;
- }
- bool twist(int a){
- int n = rever(a);
- if(prime(a) && prime(n)) return true;
- return false;
- }
- int main(){
- int t; scanf("%d", &t);
- while(t--){
- int n; scanf("%d", &n);
- (twist(n)) ? printf("Yes\n") : printf("No\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement