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;
        }
    }

}

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.