60分求助!
查看原帖
60分求助!
826774
Little_Fox_Fairy楼主2023/7/15 11:28

这是代码

#include<bits/stdc++.h>
using namespace std;
long long n,i,j,x,y,l,r,s,tot;
int main()
{
	//freopen("matrix.in","r",stdin);
	//freopen("matrix.out","w",stdout);
	cin>>n>>i>>j;
	x=n;
	y=1;
	l=i;
	r=j;
	while (x!=0&&y!=0)
	{
		if (i==y)
		{
			cout<<r+s;
			return 0;
		}
		if (i==x)
		{
			cout<<3*n-r-1+s;
			return 0;
		}
		if (j==y)
		{
			cout<<3*n+l-3+s;
			return 0;
		}
		if (j==x)
		{
			cout<<n+l-1+s;
			return 0;
		}
		s=s+4*n-4;
		x-=1;
		y+=1;
		n-=2;
		l++;
		r--;
	}
	return 0;
}

不知是哪里错了

2023/7/15 11:28
加载中...