CF1854F Mark and Spaceship

题目描述

迈克制造了一艘在 $4$ 维空间工作的宇宙飞船。他想用飞船尽可能快地完成任务。每次任务中,飞船从 $(0,0,0,0)$ 开始,需要在 $(a,b,c,d)$ 结束。为了做到这一点,他让飞船的计算机执行一系列移动,其中每个移动都是八个基本方向之一的单位步长:$(±1,0,0,0)$,$(0,±1,0,0)$,$(0,0,±1,0)$,$(0,0,0,±1)$。不幸的是,飞船的代码中有一个漏洞:第一步将执行一次,第二步将执行两次,第三步将执行三次,依此类推。现在,对于任意四个整数 $a$,$b$,$c$,$d$,设 $f(a,b,c,d)$ 是任务结束于 $(a,b,c,d)$ 的最少移动次数。计算 $f(a,b,c,d)$ 在所有点上的和。

输入格式

四个整数 $a$,$b$,$c$,$d$。

输出格式

输出 $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). $ $$$