题解
2023-05-27 17:28:02
发布于:上海
76阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
long long n, x, y;
long long get_gezi_number(long long n, long long x, long long y) {
long long cnt = 0;
long long d = min( min(x-1, n-x), min(y-1, n-y) );
cnt = ( 4 * n - 4 + 4 * (n-2*d+2) - 4 ) * d / 2;
long long x1 = d+1, Y1 = d+1, x2 = n-d, y2 = n-d;
if (x1 == x) cnt += y-Y1+1;
else if (y2 == y) cnt += (n-2*d-1) + x-x1+1;
else if (x2 == x) cnt += 2 * (n-2*d-1) + y2-y+1;
else cnt += 3 * (n-2*d-1) + x2-x+1;
return cnt;
}
int main() {
cin >> n >> x >> y;
cout << get_gezi_number(n, x, y) << endl;
return 0;
}
这里空空如也
有帮助,赞一个