CF1854F Mark and Spaceship

题目描述

马克喜欢快速移动。所以他做了一艘能在 $$$4$$$ 三维空间里工作的飞船。 他想用飞船以最快的速度完成任务。在每次任务中,飞船从 $$$(0, 0, 0, 0)$$$ 开始,需要在 $$$(a, b, c, d)$$$ 结束。为此,他指示飞船的电脑执行一系列移动,每一步都是向八个基本方向中的一个方向移动一个单位步: $$$(\pm 1, 0, 0, 0)$$$ , $$$(0, \pm 1, 0, 0)$$$ , $$$(0, 0, \pm 1, 0)$$$ , $$$(0, 0, 0, \pm 1)$$$ . 不幸的是,在建造飞船时,他的移动速度也很快,因此飞船的代码中存在一个错误。第一次移动会执行一次,第二次移动会执行两次,第三次移动会执行三次,以此类推。一般来说, $$$i$$$ \-次移动会被执行 $$$i$$$ 次。 对于任意四个整数 $$$a, b, c, d$$$ ,设 $$$f(a, b, c, d)$$$ 是一个任务的最少步数,该任务的终点是 $$$(a, b, c, d)$$$ 。计算所有点(坐标为整数)的 $$$f(a, b, c, d)$$$ 和 $$$-A\le a\le A$$$ , $$$-B\le b\le B$$$ , $$$-C\le c\le C$$$ , $$$-D\le d\le D$$$ .

输入格式

输入的唯一一行包含四个整数 $$$A, B, C, D$$$ ( $$$0\le A,B,C,D\le 1000$$$ )。

输出格式

输出 $f(a,b,c,d)$ 在所有点上的和。

说明/提示

In the first sample, one has to compute $ f(-1, 0, 0, 0)+f(0, 0, 0, 0) + f(1, 0, 0, 0) = 1 + 0 + 1 = 2 $ . In the second sample, one has to compute the sum of $ f(a, b, c, d) $ over $ 27 $ different points $ (a, b, c, d) $ . Let us describe the value of $ f(a, b, c, d) $ for some of them: - It holds $ f(-1, 0, 0, -1)=3 $ and it may be achieved with the following sequence of moves (an arrow $ \xrightarrow{\pm i} $ denotes that the move is performed on the $ i $ -th coordinate): $ $$$(0, 0, 0, 0) \xrightarrow{-1} (-1, 0, 0, 0) \xrightarrow{+4} (-1, 0, 0, 2) \xrightarrow{-4} (-1, 0, 0, -1). $ $
  • It holds $ f(1, 1, 0, 1) = 5 $ and it may be achieved with the following sequence of moves: $ $ (0, 0, 0, 0) \xrightarrow{+1} (1, 0, 0, 0) \xrightarrow{-2} (1, -2, 0, 0) \xrightarrow{+2} (1, 1, 0, 0) \xrightarrow{-4} (1, 1, 0, -4) \xrightarrow{+4} (1, 1, 0, 1). $ $
  • In the third sample, one has to compute the sum of $ f(a, b, c, d) $ over $ 7\\cdot5\\cdot 9\\cdot 3 $ points. One of them is $ (3, 2, 4, 1) $ . It holds $ f(3, 2, 4, 1) = 4 $ and it may be achieved with the following sequence of moves: $ $ (0, 0, 0, 0) \xrightarrow{+4} (0, 0, 0, 1) \xrightarrow{+2} (0, 2, 0, 1) \xrightarrow{+1} (3, 2, 0, 1) \xrightarrow{+3} (3, 2, 4, 1). $ $$$