blob: a3b8810022b984e7cb48c8bde93a2af4d8698a35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <cmath>
#include <iostream>
using ll = long long;
int main() {
ll X, Y;
std::cin >> X >> Y;
ll result = 0;
if (X == 0 && Y == 0) {
return 0;
}
if (std::abs(X) > std::abs(Y) ||
(std::abs(X) == std::abs(Y) && !(X < 0 && Y < 0))) {
ll c = std::abs(X);
result += ((c - 1) * 4 + 2) * (c - 1);
if (X > 0) {
result += (c * 2 - 1) * 2;
result += c * 2;
result += (c - Y);
} else {
result += (c * 2 - 1);
result += (Y - (-c + 1));
}
} else {
ll c = std::abs(Y);
result += ((c - 1) * 4 + 2) * (c - 1);
if (Y > 0) {
result += (c * 2 - 1) * 2;
result += (X - (-c));
} else {
result += (c * 2 - 1) * 2;
result += c * 2 * 2;
result += c - X;
}
}
std::cout << result;
return 0;
}
|