#include #include #include #include #include using namespace std; //なんという効率の悪いコード。 int main(){ int goaly,goalx; int tekiy,tekix; int goaly_h,goalx_h; int tekiy_h,tekix_h; int adjust = 0; cin >> goalx >> goaly >> tekix >> tekix; //縦か横 if(goaly == 0 && goalx == 0){ //符号調査 if(goaly == 0){ goaly_h = 0; }else if(goaly < 0){ goaly_h = -1; }else{ goaly_h = 1; } if(goalx == 0){ goalx_h = 0; }else if(goalx < 0){ goalx_h = -1; }else{ goalx_h = 1; } if(tekiy == 0){ tekiy_h = 0; }else if(tekiy < 0){ tekiy_h = -1; }else{ tekiy_h = 1; } if(tekix == 0){ tekix_h = 0; }else if(tekix < 0){ tekix_h = -1; }else{ tekix_h = 1; } if(goaly_h == tekiy_h && goalx_h == tekix_h){ adjust = 1; }else{ adjust = 0; } //斜め }else if(abs(goaly) == abs(goalx)){ //符号調査 if(goaly < 0){ goaly_h = -1; }else{ goaly_h = 1; } if(goalx < 0){ goalx_h = -1; }else{ goalx_h = 1; } if(tekiy < 0){ tekiy_h = -1; }else{ tekiy_h = 1; } if(tekix < 0){ tekix_h = -1; }else{ tekix_h = 1; } //斜め if(abs(tekiy) == abs(tekix) && goaly_h == tekiy_h && goalx_h == tekix_h){ adjust = 1; }else{ adjust = 0; } }else{ adjust = 0; } cout << max(abs(goaly), abs(goalx)) + adjust << endl; return 0; }