CF1854F.Mark and Spaceship
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mark loves to move fast. So he made a spaceship that works in 4-dimensional space.
He wants to use the spaceship to complete missions as fast as possible. In each mission, the spaceship starts at (0,0,0,0) and needs to end up at (a,b,c,d). To do this, he instructs the spaceship's computer to execute a series of moves, where each move is a unit step in one of the eight cardinal directions: (±1,0,0,0), (0,±1,0,0), (0,0,±1,0), (0,0,0,±1).
Unfortunately, he also moved fast when building the spaceship, so there is a bug in the spaceship's code. The first move will be executed once, the second move will be executed twice, the third move will be executed thrice, and so on. In general, the i-th move will be executed i times.
For any four integers a,b,c,d, let f(a,b,c,d) be the minimum number of moves of a mission that ends up at (a,b,c,d). Compute the sum of f(a,b,c,d) over all points (with integer coordinates) such that −A≤a≤A, −B≤b≤B, −C≤c≤C, −D≤d≤D.
马克喜欢快速移动。因此,他制造了一艘在四维空间中运行的宇宙飞船。
他希望利用这艘宇宙飞船尽快完成任务。在每项任务中,宇宙飞船从 (0,0,0,0) 出发,最终需抵达 (a,b,c,d)。为此,他向飞船的计算机下达一系列移动指令,每次移动均为沿八个基本方向之一的单位步长:(±1,0,0,0)、(0,±1,0,0)、(0,0,±1,0)、(0,0,0,±1)。
不幸的是,他在建造飞船时也过于匆忙,导致飞船代码中存在一个 Bug:第 1 次移动将被执行 1 次,第 2 次移动将被执行 2 次,第 3 次移动将被执行 3 次,依此类推;一般地,第 i 次移动将被执行 i 次。
对任意四个整数 a,b,c,d,记 f(a,b,c,d) 为抵达目标点 (a,b,c,d) 所需的最少移动次数(即指令序列长度)。请计算所有满足 −A≤a≤A、−B≤b≤B、−C≤c≤C、−D≤d≤D 的整数坐标点 (a,b,c,d) 对应的 f(a,b,c,d) 之和。
输入格式
The only line of the input contains the four integers A,B,C,D (0≤A,B,C,D≤1000).
输入仅包含一行,其中有四个整数 A,B,C,D(0≤A,B,C,D≤1000)。
输出格式
Print the sum of f(a,b,c,d) over the set of points described in the statement.
输出在题目描述中所述点集上 f(a,b,c,d) 的和。
输入输出样例
输入#1
1 0 0 0
输出#1
2
输入#2
1 1 0 1
输出#2
82
输入#3
3 2 4 1
输出#3
4616
说明/提示
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 ±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⋅5⋅9⋅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).$$
在第一个样例中,需要计算 f(−1,0,0,0)+f(0,0,0,0)+f(1,0,0,0)=1+0+1=2。
在第二个样例中,需要计算 f(a,b,c,d) 在 27 个不同点 (a,b,c,d) 上的和。下面列举其中部分点处的函数值 f(a,b,c,d):
- f(−1,0,0,−1)=3,可通过如下移动序列实现(箭头 ±i 表示对第 i 个坐标执行移动): $$(0, 0, 0, 0) \xrightarrow{-1} (-1, 0, 0, 0) \xrightarrow{+4} (-1, 0, 0, 2) \xrightarrow{-4} (-1, 0, 0, -1).$$
- f(1,1,0,1)=5,可通过如下移动序列实现: $$(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).$$
在第三个样例中,需要计算 f(a,b,c,d) 在 7⋅5⋅9⋅3 个点上的和。其中一个点为 (3,2,4,1)。此时有 f(3,2,4,1)=4,可通过如下移动序列实现: $$(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).$$
输入解题思路,AI测评打分。不知道怎么写?