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

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

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

Powered by Blogger.