#include <iostream>
#include <cmath>
using namespace std;
void f(int w, int n, int &x, int &y)
{
x = (n - 1) / w;
y = (n - 1) % w;
if (x % 2 != 0)
y = w - 1 - y;
}
int main()
{
int w, m, n, x1, y1, x2, y2;
cin >> w >> m >> n;
f(w, m, x1, y1);
f(w, n, x2, y2);
cout << abs(x1 - x2) + abs(y1 - y2) << endl;
return 0;
}
c++
最新推荐文章于 2024-11-06 23:59:11 发布