UVA 10235 - Simply Emirp

UVA Aug 31, 2020

Problem PDF

Solution:

#include
#include
#include
int main()
{
long long i,c,d,num,j,p,n;
while(scanf("%lld",&num)==1)
{
p=num;
i=2;
while(i<=num)
{
if(num%i==0)
break;
i++;
}

n=0;
while(num!=0)
{
n=n*10+num%10;
num/=10;
}


j=2;
while(j<=n)
{
if(n%j==0)
break;
j++;
}
if(p==2)
printf("%lld is prime.\n",p);
else if((j==n)&&(i==p))
printf("%lld is erime.\n",p);
else if(i==p)
printf("%lld is prime.\n",p);
else
printf("%lld is not prime.\n",p);


}
return 0;
}

https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/10235/10235.cpp

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.