- /****************##### بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم #####******************
- __________________________________________________________________________
- ###################### Ya-Seen Arafat(ACWizard) #########################
- ###################### UAP-CSE-33B #########################
- *************************************************************************/
- #include <bits/stdc++.h>
- #define M 1000003
- #define S 1000003
- #define LL long long
- using namespace std;
- int main(){
- int t, cs = 0;
- LL x1, x2, y1, y2;
- LL a, b;
- scanf("%d", &t);
- while(t--){
- scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
- LL p, q;
- if(x1 < 0 && x2 < 0)p = abs(abs(x1)-abs(x2));
- else if(x1 >= 0 && x2 >= 0)p = abs(x1-x2);
- else if(x1 < 0 && x2 >= 0)p = abs(x1)+x2;
- else p = x1+abs(x2);
- if(y1 < 0 && y2 < 0)q = abs(abs(y1)-abs(y2));
- else if(y1 >= 0 && y2 >= 0)q = abs(y1-y2);
- else if(y1 < 0 && y2 >= 0)q = abs(y1)+y2;
- else q = y1+abs(y2);
- LL ans = __gcd(p, q)+1;
- printf("Case %d: %lld\n", ++cs, ans);
- }
- return 0;
- }
Sunday, February 28, 2016
LightOJ - 1077 - How Many Points?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment