tj
2025-07-07 21:03:11
发布于:上海
6阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,y;
cin>>n>>x>>y;
int rx=1,num=y;
int top=1,bottom=n,left=1,right=n;
bool fx=true;
while(rx!=x){
if(fx){
if(right==y){
num+=x-rx;
break;
}
}
else{
if(left==y){
num+=rx-x;
break;
}
}
if(fx){
num+=(right-y+1)*2+bottom-rx-2;
rx=bottom;
right--;
top++;
}
else{
num+=(y-left+1)*2+rx-top-2;
rx=top;
left++;
bottom--;
}
fx=!fx;
}
cout<<num;
return 0;
}
这里空空如也
有帮助,赞一个