#include<cstdio>
#include<cstring>
#include<cstdlib>
int xxx(int y, int z){
int w;
if (y < z){
if (z%y == 0)return y;
else {
w = z / y;
return xxx(y, z - (w*y));
}
}
else if (z < y){
if (y%z == 0)return z;
else {
w = y / z;
return xxx(z, y - (w*z));
}
}
else return y;
}
int main(void){
int a,b,c,d;
int x;
int p, q;
long long s;
scanf("%d%d %d %d", &a,&b,&c,&d);
p = c - a;
q = d - b;
if (p != 0 && q != 0){
if (p < 0)p = -p;
if (q < 0)q = -q;
x = xxx(p, q);
p = p / x;
q = q / x;
s = (p + q - 1)*x;
printf("%lld\n", s);
}
else printf("0\n");
return 0;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d %d %d", &a,&b,&c,&d);
^