80分求助
查看原帖
80分求助
806720
sea_water楼主2024/10/12 21:05
#include <bits/stdc++.h>
using namespace std;
int n2, x, y;

int dfs(int n, int i, int j) {
	int t = n2 * n2 - n * n;
	if (x == i)
		return t + y;
	if (y == n)
		return t + x - 1;
	if (x == n)
		return t + 3 * n - y - 1;
	if (y == j)
		return t + 4 * n - x - 2;
	x -= 1, y -= 1;
	return dfs(n - 2, i, j );
}

int main() {
	cin >> n2 >> x >> y;
	cout << dfs(n2, 1, 1);
	return 0;
}
2024/10/12 21:05
加载中...