简单模拟
#include<bits/stdc++.h>
using namespace std;
int main()
{
int w,m,n;
cin>>w>>m>>n;
if(m>n)swap(m,n);
int x=m;
int a=(m-1)/w,b=(n-1)/w;
int d=0,step=0;
for(int r=a+1;r<=b;r++){
if((r-1)&1==0 && r&1)d=2*w-(x%w)-1;
else d=(w-x%w)*2+1;
step++;
// cout<<"d:"<<d<<endl;
// cout<<"step:"<<step<<endl;
x+=d;
// cout<<"x:"<<x<<endl;
}
step+=abs(x-n);
cout<<step<<endl;
return 0;
}
0 回复
0 转发
0 喜欢
1 阅读



