#include <bits/stdc++.h>
using namespace std;
int n,l,h;
int q = 1,a[30001][30001];
int main()
{
cin >> n;
cin >> h >> l;
int t = n / 2;
if(n % 2 == 1) t++;
for(int i = 0;i < t;i++)
{
for(int j = i;j < n-i;j++)
{
a[i][j] = q++;
}
for(int j = i+1;j < n-i-1;j++)
{
a[j][n-i-1] = q++;
}
for(int j = n-i-1;j > i;j--)
{
a[n-i-1][j] = q++;
}
for(int j = n-i-1;j > i;j--)
{
a[j][i] = q++;
}
}
cout << a[h-1][l-1];
return 0;
}
借鉴了亿点P5731的代码,butCE了,怎么改…