本题可以找规律来写
只要找出四个角的规律,然后加上偏移量就行
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
int main()
{
int x,y,n;
cin >> x >> y;
if(abs(x) <= y)
{
n = y;
cout << (LL) (2 * n - 1) * (2 * n) + x - (-n) << endl;
}
else if(abs(y) <= x)
{
n = x;
cout << (LL)(2 * n) * (2 * n) + n - y << endl;
}
else if(abs(x) <= abs(y) + 1 && y < 0)
{
n = abs(y);
cout << (LL)(2 * n) * (2 * n + 1) + n - x << endl;
}
else
{
n = abs(x);
cout << (LL)(2 * n - 1) * (2 * n - 1) + y - (-n + 1) << endl;
}
return 0;
}