题目描述


题目分析

在图中我们可以观察到四个对角线的值均为特殊点,其他的点可以根据这几个 进行偏移量的计算从而进行表示,此题主要是找到规律即可
cpp
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll x, y, n;
cin >> x >> y;
if(abs(x) <= y)//在上方
{
n = y;
cout << (ll)(2 * n - 1) * (2 * n) + x - (-n) << '\n';
}
else if(abs(y) <= x)//在右方
{
n = x;
cout << (ll)(2 * n) * (2 * n) + n - y << '\n';
}
else if(abs(x) <= abs(y) + 1 && y < 0)//在下方
{
n = abs(y);
cout << (ll)(2 * n) * (2 * n + 1) + n - x << '\n';
}
else//在左方
{
n = abs(x);
cout << (ll)(2 * n - 1) * (2 * n - 1) + y - (- n + 1) << '\n';
}
return 0;
}