Light Oj solution 1077 - How Many Points?

Solve in C:

#include<stdio.h>
long long int hcf(long long int m1,long long  int m2)
{
    if (m2 != 0)
        return hcf(m2, m1%m2);
    else
        return m1;
}
int main()
{
    long long int i,x1,y1,x2,y2,n,r,p,q,m,j,n1,n2,gcd;
    scanf("%lld",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
        n1=y2-y1;
        n2=x2-x1;
        if(n1<0)
        {
            n1=-1*n1;
        }
        if(n2<0)
        {
            n2=-1*n2;
        }
        p= hcf( n1, n2);
        printf("Case %lld: %lld\n",i,p+1);
    }
}

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.