http://oj.ecustacm.cn/problem.php?id=1261
#include<cstdio>
#include<iostream>
using namespace std;
int w,m,n;
int x1,y1;
int x2,y2;
int main(void)
{
while(cin>>w>>m>>n)
{
m--,n--;
x1=m/w;
x2=n/w;
if(x1&1) y1=w-1-m%w;
else y1=m%w;
if(x2&1) y2=w-1-n%w;
else y2=n%w;
cout<<abs(x1-x2)+abs(y1-y2)<<endl;
}
return 0;
}