G. The Special King
题目链接-G. The Special King
题目大意
棋盘上一个国王可以从它的位置向上、向下、向左或向右移动,最初,特殊的国王站在位置
(
x
1
,
y
1
)
(x1,y1)
(x1,y1)上,请你求出把它移动到位置
(
x
2
,
y
2
)
(x2,y2)
(x2,y2)上所需的最小步数
解题思路
没什么说的,最小步数就是x轴方向距离的绝对值和y轴方向距离的绝对值之和
附上代码
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=2e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--){
int a,b,c,d;
cin>>a>>b>>c>>d;
cout<<abs(a-c)+abs(b-d)<<endl;
}
return 0;
}