A16137 | Mark and Spaceship
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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: $(\pm 1, 0, 0, 0)$ , $(0, \pm 1, 0, 0)$ , $(0, 0, \pm 1, 0)$ , $(0, 0, 0, \pm 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\le a\le A$ , $-B\le b\le B$ , $-C\le c\le C$ , $-D\le d\le D$ .
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: $(\pm 1, 0, 0, 0)$ , $(0, \pm 1, 0, 0)$ , $(0, 0, \pm 1, 0)$ , $(0, 0, 0, \pm 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\le a\le A$ , $-B\le b\le B$ , $-C\le c\le C$ , $-D\le d\le D$ .
输入格式
The only line of the input contains the four integers $A, B, C, D$ ( $0\le A,B,C,D\le 1000$ ).
输出格式
Print the sum of $f(a, b, c, d)$ over the set of points described in the statement.
输入输出样例
输入 #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 $\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). $$ </li><li> 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). $$ </li></ul><p>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). $$$$
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). $$ </li><li> 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). $$ </li></ul><p>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). $$$$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted