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

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.