- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long int
- ll gcd(ll a, ll b){
- //if(a<b) swap(a, b);
- while(a){
- ll temp = a;
- a = b%a;
- b = temp;
- //cout<<"temp a b"<<temp<<" "<<a<<" "<<b<<" ";
- }
- return b;
- }
- /*
- ll gcd(ll b,ll a){
- ll tmp;
- while(b){
- tmp = b;
- b = a%b;
- a = tmp;
- cout<<"temp a b"<<tmp<<" "<<a<<" "<<b<<" ";
- }
- return a;
- }
- */
- int main(){
- int ts;
- //cdcout<<gcd(10, 15);
- cin>>ts;
- for(int i = 1; i <= ts; i++){
- ll x1, y1, x2, y2;
- scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
- ll ans;
- ll dx = abs(x1-x2);
- ll dy = abs(y1-y2);
- if(dx == 0) ans = dy+1;
- else if(dy == 0) ans = dx+1;
- else ans = gcd(dx, dy)+1;
- printf("Case %d: %lld\n", i, ans);
- }
- return 0;
- }
Friday, 28 July 2017
Lightoj 1077 - How Many Points?
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
-
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
No comments:
Post a Comment