首页 > 其他分享 >Codeforces Round #143 (Div. 2)-D. Magic Box

Codeforces Round #143 (Div. 2)-D. Magic Box

时间:2023-06-12 18:06:40浏览次数:54  
标签:Box Vasya Magic 143 point box numbers y1 z1


原题链接


D. Magic Box



time limit per test



memory limit per test



input



output



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 (x1, y1, z1). The six faces of the box contain some numbers a1, a2, ..., a6, exactly one number right in the center of each face.



Codeforces Round #143 (Div. 2)-D. Magic Box_#include


The numbers are located on the box like that:

  • number a1
  • a2
  • a3
  • a4
  • a5
  • a6

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 ai numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some ai, then he can't mistake this number for 9



Input



The fist input line contains three space-separated integers xy and z (|x|, |y|, |z| ≤ 106) — the coordinates of Vasya's position in space. The second line contains three space-separated integers x1, y1, z1 (1 ≤ x1, y1, z1 ≤ 106) — 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 a1, a2, ..., a6 (1 ≤ ai ≤ 106) — the numbers that are written on the box faces.

It is guaranteed that point (x, y, z)



Output



Print a single integer — the sum of all numbers on the box faces that Vasya sees.



Examples



input



2 2 2
1 1 1
1 2 3 4 5 6



output



12



input



0 0 10
3 2 3
1 2 3 4 5 6



output



4



Note



The first sample corresponds to perspective, depicted on the picture. Vasya sees numbers a2 (on the top face that is the darkest), a6(on the right face that is the lightest) and a4

In the second sample Vasya can only see number a4.





#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;
typedef long long ll;

int main(){
	
//	 freopen("in.txt", "r", stdin);
	 int a[7];
	 int x, y, z, x1, y1, z1;
	 
	 scanf("%d%d%d%d%d%d", &x, &y, &z, &x1, &y1, &z1);
	 for(int i = 1; i <= 6; i++)
	  scanf("%d", a+i);
	int s = 0;
	if(y > y1)
	 s += a[2];
	if(y < 0)
	 s += a[1];
	if(z > z1)
	 s += a[4];
	if(z < 0)
	 s += a[3];
	if(x > x1)
	 s += a[6];
	if(x < 0)
	 s += a[5];
	cout << s << endl;
	
	return 0;
}





标签:Box,Vasya,Magic,143,point,box,numbers,y1,z1
From: https://blog.51cto.com/u_16158872/6464554

相关文章

  • 51nod-1434 区间LCM
    原题链接1434 区间LCM题目来源: TopCoder基准时间限制:1 秒空间限制:131072 KB分值: 40 难度:4级算法题 收藏 关注例如,LCM(2)=2,LCM(4,6)=12,LCM(1,2,3,4,5)=60。现在给定一个整数N(1<=N<=1000000),需要找到......
  • Flutter的FittedBox控件
    简介FittedBox是Flutter中的一个控件,它用于调整其子控件的大小以适应可用空间。它会根据子控件的大小和可用空间的大小,自动进行缩放或拉伸操作,以使子控件恰好填充可用空间。属性FittedBox的常用属性包括:fit:指定子控件如何适应可用空间的枚举值。常用的取值有:BoxFit.contain:将......
  • Magick.NET跨平台压缩图片的用法
    //首先NuGet安装:Magick.NET.Core,Magick.NET-Q16-AnyCPUusingImageMagick;///<summary>///压缩图片///</summary>///<paramname="imageData">图片字节流</param>///<paramname="maxWidth"&......
  • hackthebox flight insane
    主机发现nmap-sV-sC-oNflight10.10.11.18788端口开放所以是一个域环境tips:在域环境中,只要与kerberos相关的事情,必须要与域环境中的时间一致域环境smbenum主机头由于开放了445端口,首先用cme枚举445端口cmd--help枚举可用常规选项cmesmb--help查看smb内的选项......
  • 算法学习day53动态规划part14-1143、53、1035
    packageLeetCode.DPpart14;/***1143.最长公共子序列*给定两个字符串text1和text2,返回这两个字符串的最长公共子序列的长度。*如果不存在公共子序列,返回0。*一个字符串的子序列是指这样一个新的字符串:它是由原字符串在不改变字符的相对顺序的情况下删除某些......
  • blackbox-exporter面板优化
     修改前,响应时间里的接口都是真实不好记忆的 修改后,方便业务员查看 效果查看 ......
  • VirtualBox 导入/注册 虚拟机文件 .vbox 失败
    VirtualBox导入/注册虚拟机文件.vbox失败问题情景Error:Failedtoopenvirtualmachinelocatedin<.vbox所在目录>.ErrorinJ:\<.vbox所在目录>(line59)--Invalidvalue'WAS'inAudioAdapter/@driverattribute.F:\tinderbox\win-6.1\src\VBox\Main......
  • .NET Developer Tools - What you should (could) have in your toolbox zz
    .NETDeveloperTools-Whatyoushould(could)haveinyourtoolboxSubmittedbyDenDelimarskyonSun,2010/12/26-9:26pm//z2011-12-202:34PMis2120@ScottHanslemanhasaprettydecentlistofsoftwaretoolsthatmightbeusefulfordeveloperandregul......
  • python tkinter 动态批量建立Widget时,combobox 或 entry传递参数问题
    terminal_combobox.bind('<<ComboboxSelected>>',lambdaevent,arg=key_dict:self.terminal_select(key_dict=arg))#注意,传递参数方法defterminal_select(self,key_dict,*args):var=self.dict_widget[key_d......
  • C# TextBox 控件添加提示
     //Lostfocus当一个控件失去焦点时触发,定义控件失去焦点时的方法this.textBox1.LostFocus+=newSystem.EventHandler(this.textBox1_LostFocus);//GotFocus是在一个对象得到焦点时发生,定义控件得到焦点时的方法this.textBox1.GotFocus+=newSystem.EventHandler(th......