1219. 移动距离
题目链接https://www.acwing.com/problem/content/1221/
题目:
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
int w,n,m;
cin>>w>>n>>m;
int x1,x2,y1,y2;
n--;
m--;
x1=n/w;
x2=m/w;
if(x1%2==0) y1=n%w;
else y1=w-n%w-1;
if(x2%2==0) y2=m%w;
else y2=w-m%w-1;
//cout<<x1<<" "<<y1<<endl;
//cout<<x2<<" "<<y2<<endl;
printf("%d",abs(x2-x1)+abs(y2-y1));
return 0;
}