Sunday, February 28, 2016

LightOJ - 1077 - How Many Points?

  1. /****************#####    بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم   #####******************
  2. __________________________________________________________________________
  3. ######################  Ya-Seen Arafat(ACWizard) #########################
  4. ######################        UAP-CSE-33B        #########################
  5. *************************************************************************/
  6. #include <bits/stdc++.h>
  7. #define M 1000003
  8. #define S 1000003
  9. #define LL long long
  10. using namespace std;
  11.  
  12. int main(){
  13.     int t, cs = 0;
  14.     LL x1, x2, y1, y2;
  15.     LL a, b;
  16.     scanf("%d"&t);
  17.     while(t--){
  18.         scanf("%lld %lld %lld %lld"&x1, &y1, &x2, &y2);
  19.         LL p, q;
  20.         if(x1 < 0 && x2 < 0)= abs(abs(x1)-abs(x2));
  21.         else if(x1 >= 0 && x2 >= 0)= abs(x1-x2);
  22.         else if(x1 < 0 && x2 >= 0)= abs(x1)+x2;
  23.         else p = x1+abs(x2);
  24.  
  25.         if(y1 < 0 && y2 < 0)= abs(abs(y1)-abs(y2));
  26.         else if(y1 >= 0 && y2 >= 0)= abs(y1-y2);
  27.         else if(y1 < 0 && y2 >= 0)= abs(y1)+y2;
  28.         else q = y1+abs(y2);
  29.  
  30.         LL ans = __gcd(p, q)+1;
  31.         printf("Case %d: %lld\n"++cs, ans);
  32.     }
  33.     return 0;
  34. }

No comments:

Post a Comment