#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
using namespace std;
bool isPrime(int x)
{
int square=sqrt(x);
ff(i,2,square+1){
if(x%i==0){
return false;
break;
}
}
return true;
}
int main()
{
int cse=0,cnt=0,flg=0;
string s="", org="";
while(getline(cin,s,'\n')){
org=s;
int num=atoi(s.c_str());
if(isPrime(num)==true){
reverse(s.begin(),s.end());
if(s!=org){
num=atoi(s.c_str());
if(isPrime(num)==true)
cout<<org<<" is emirp.\n";
else
cout<<org<<" is prime.\n";
}
else
cout<<org<<" is prime.\n";
}
else
cout<<org<<" is not prime.\n";
}
return 0;
}
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
using namespace std;
bool isPrime(int x)
{
int square=sqrt(x);
ff(i,2,square+1){
if(x%i==0){
return false;
break;
}
}
return true;
}
int main()
{
int cse=0,cnt=0,flg=0;
string s="", org="";
while(getline(cin,s,'\n')){
org=s;
int num=atoi(s.c_str());
if(isPrime(num)==true){
reverse(s.begin(),s.end());
if(s!=org){
num=atoi(s.c_str());
if(isPrime(num)==true)
cout<<org<<" is emirp.\n";
else
cout<<org<<" is prime.\n";
}
else
cout<<org<<" is prime.\n";
}
else
cout<<org<<" is not prime.\n";
}
return 0;
}
No comments:
Post a Comment