题目
代码
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[6] = {-1, -1, 0, 1, 1, 0};
int dy[6] = {0, 1, 1, 0, -1, -1};
void cal(int d, int p, int q, int& x, int& y)
{
x += p * dx[d];
y += p * dy[d];
d = (d + 2) % 6;
x += q * dx[d];
y += q * dy[d];
}
int main()
{
int d1, p1, q1, d2, p2, q2;
cin >> d1 >> p1 >> q1 >> d2 >> p2 >> q2;
int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
cal(d1, p1, q1, x1, y1);
cal(d2, p2, q2, x2, y2);
ll ans = 0;
ll X = x2 - x1, Y = y2 - y1;
if(abs(X + Y) < abs(X) + abs(Y)) ans = max(abs(X), abs(Y));
else ans = abs(X) + abs(Y);
cout << ans;
}