Codeforces 1033B Square Difference Solution
Solve in c:
#include<stdio.h>
#include<math.h>
int main()
{
long long int a,b,count=0,i,j,t;
while(scanf("%lld",&t)!=EOF)
{
for(j=1; j<=t; j++)
{
scanf("%lld%lld",&a,&b);
{
if(a-b==1)
{
for(i=2; i<=sqrt(a+b); i++)
{
if((a+b)%i==0)
count++;
}
if(count==0)
printf("YES\n");
else
printf("NO\n");
}
else
printf("NO\n");
}
count=0;
}
}
}
#include<stdio.h>
#include<math.h>
int main()
{
long long int a,b,count=0,i,j,t;
while(scanf("%lld",&t)!=EOF)
{
for(j=1; j<=t; j++)
{
scanf("%lld%lld",&a,&b);
{
if(a-b==1)
{
for(i=2; i<=sqrt(a+b); i++)
{
if((a+b)%i==0)
count++;
}
if(count==0)
printf("YES\n");
else
printf("NO\n");
}
else
printf("NO\n");
}
count=0;
}
}
}
No comments