A8713 | Magic Box
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point $(0,0,0)$ , and the opposite one is at point $(x_{1},y_{1},z_{1})$ . The six faces of the box contain some numbers $a_{1},a_{2},...,a_{6}$ , exactly one number right in the center of each face.
The numbers are located on the box like that:
- number $a_{1}$ is written on the face that lies on the ZOX plane;
- $a_{2}$ is written on the face, parallel to the plane from the previous point;
- $a_{3}$ is written on the face that lies on the XOY plane;
- $a_{4}$ is written on the face, parallel to the plane from the previous point;
- $a_{5}$ is written on the face that lies on the YOZ plane;
- $a_{6}$ is written on the face, parallel to the plane from the previous point.
At the moment Vasya is looking at the box from point $(x,y,z)$ . Find the sum of numbers that Vasya sees. Note that all faces of the box are not transparent and Vasya can't see the numbers through the box. The picture contains transparent faces just to make it easier to perceive. You can consider that if Vasya is looking from point, lying on the plane of some face, than he can not see the number that is written on this face. It is enough to see the center of a face to see the corresponding number for Vasya. Also note that Vasya always reads correctly the $a_{i}$ numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some $a_{i}=6$ , then he can't mistake this number for $9$ and so on).
The numbers are located on the box like that:
- number $a_{1}$ is written on the face that lies on the ZOX plane;
- $a_{2}$ is written on the face, parallel to the plane from the previous point;
- $a_{3}$ is written on the face that lies on the XOY plane;
- $a_{4}$ is written on the face, parallel to the plane from the previous point;
- $a_{5}$ is written on the face that lies on the YOZ plane;
- $a_{6}$ is written on the face, parallel to the plane from the previous point.
At the moment Vasya is looking at the box from point $(x,y,z)$ . Find the sum of numbers that Vasya sees. Note that all faces of the box are not transparent and Vasya can't see the numbers through the box. The picture contains transparent faces just to make it easier to perceive. You can consider that if Vasya is looking from point, lying on the plane of some face, than he can not see the number that is written on this face. It is enough to see the center of a face to see the corresponding number for Vasya. Also note that Vasya always reads correctly the $a_{i}$ numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some $a_{i}=6$ , then he can't mistake this number for $9$ and so on).
输入格式
The fist input line contains three space-separated integers $x$ , $y$ and $z$ ( $|x|,|y|,|z|<=10^{6}$ ) — the coordinates of Vasya's position in space. The second line contains three space-separated integers $x_{1}$ , $y_{1}$ , $z_{1}$ ( $1<=x_{1},y_{1},z_{1}<=10^{6}$ ) — the coordinates of the box's vertex that is opposite to the vertex at point $(0,0,0)$ . The third line contains six space-separated integers $a_{1},a_{2},...,a_{6}$ ( $1<=a_{i}<=10^{6}$ ) — the numbers that are written on the box faces.
It is guaranteed that point $(x,y,z)$ is located strictly outside the box.
It is guaranteed that point $(x,y,z)$ is located strictly outside the box.
输出格式
Print a single integer — the sum of all numbers on the box faces that Vasya sees.
输入输出样例
输入 #1
2 2 2 1 1 1 1 2 3 4 5 6
输出 #1
12
输入 #2
0 0 10 3 2 3 1 2 3 4 5 6
输出 #2
4
The first sample corresponds to perspective, depicted on the picture. Vasya sees numbers $a_{2}$ (on the top face that is the darkest), $a_{6}$ (on the right face that is the lightest) and $a_{4}$ (on the left visible face).
In the second sample Vasya can only see number $a_{4}$ .
In the second sample Vasya can only see number $a_{4}$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted