Problem description

A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher got very angry at Vasya and decided to teach him a lesson. He gave the lazy student a seemingly easy task: You are given an idle body in space and the forces that affect it. The body can be considered as a material point with coordinates (0; 0; 0). Vasya had only to answer whether it is in equilibrium. "Piece of cake" — thought Vasya, we need only to check if the sum of all vectors is equal to 0. So, Vasya began to solve the problem. But later it turned out that there can be lots and lots of these forces, and Vasya can not cope without your help. Help him. Write a program that determines whether a body is idle or is moving by the given vectors of forces.

Input

The first line contains a positive integer n (1 ≤ n ≤ 100), then follow n lines containing three integers each: the xi coordinate, the yi coordinate and the zicoordinate of the force vector, applied to the body ( - 100 ≤ xi, yi, zi ≤ 100).

Output

Print the word "YES" if the body is in equilibrium, or the word "NO" if it is not.

Examples

Input

3
4 1 7
-2 4 -1
1 -5 -3

Output

NO

Input

3
3 -1 7
-5 2 -4
2 -1 -3

Output

YES
解题思路:题目的意思就是检查n行3列中每一列数字之和是否都为0,是的话为"YES",否则为"NO",水过。
AC代码:
 #include<bits/stdc++.h>
using namespace std;
int main(){
int n,a[][],b[];
cin>>n;
memset(b,,sizeof(b));
for(int i=;i<n;++i){
for(int j=;j<;++j){
cin>>a[i][j];b[j]+=a[i][j];
}
}
bool flag=false;
for(int i=;i<;++i)
if(b[i]!=){flag=true;break;}
if(flag)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
return ;
}

C - Young Physicist的更多相关文章

  1. codeforces水题100道 第九题 Codeforces Beta Round #63 (Div. 2) Young Physicist (math)

    题目链接:http://www.codeforces.com/problemset/problem/69/A题意:给你n个三维空间矢量,求这n个矢量的矢量和是否为零.C++代码: #include & ...

  2. codeforcess水题100道

    之所以在codeforces上找这100道水题的原因是为了巩固我对最近学的编程语言的掌握程度. 找的方式在codeforces上的PROBLEMSET中过的题最多的那些题里面出现的最前面的10个题型, ...

  3. Lesson 17 Always young

    Text My aunt Jennifer is an actress. She must be at least thirty-five years old. In spit of this, sh ...

  4. 斯考特·杨(Scott Young)快速学习方法

    上午在网上看到了斯考特·杨(Scott Young)的快速学习方法,感觉很受鼓舞. 现在已经读研究生了,可是发现自己自从上大学以来到现在,发现自己的学习方法有很大的问题. 我是个特别喜欢读书的人,在大 ...

  5. Young氏矩阵

    一个 m x n 的Young氏矩阵是指,每一行数据都是从左到右排好序,每一列的数据也都是从上到下排好序.其中也可能存在一些INF的数据,表示不存在的元素,一个mxn的Young氏矩阵最多用来存放 r ...

  6. ural 1157. Young Tiler

    1157. Young Tiler Time limit: 1.0 secondMemory limit: 64 MB One young boy had many-many identical sq ...

  7. 算法导论 第六章 思考题6-3 Young氏矩阵

    这题利用二叉堆维持堆性质的办法来维持Young氏矩阵的性质,题目提示中写得很清楚,不过确实容易转不过弯来. a,b两问很简单.直接看c小问: 按照Young氏矩阵的性质,最小值肯定在左上角取得,问题在 ...

  8. 【杨氏矩阵+勾长公式】POJ 2279 Mr. Young's Picture Permutations

    Description Mr. Young wishes to take a picture of his class. The students will stand in rows with ea ...

  9. The Sorrows of Young Werther

    The Sorrows of Young Werther J.W. von Goethe Thomas Carlyle and R.D. Boylan Edited by Nathen Haskell ...

随机推荐

  1. 图像局部显著性—点特征(Fast)

    fast作为几乎最快的角点检测算法,一般说明不附带描述子.参考综述:图像的显著性检测--点特征 详细内容,请拜访原=文章:Fast特征点检测算法 在局部特征点检测快速发展的时候,人们对于特征的认识也越 ...

  2. KVM之virsh管理虚拟机内存

    调整内存 virsh setmem 命令帮助: [root@ubuntu ~]# virsh setmem --help NAME setmem - change memory allocation ...

  3. 【udacity】机器学习-knn最近邻算法

    Evernote Export 1.基于实例的学习介绍 不同级别的学习,去除所有的数据点(xi​,yi​),然后放入一个数据库中,下次直接提取数据 但是这样的实现方法将不能进行泛化,这种方式只能简单的 ...

  4. 物理cpu与逻辑cpu概述

    物理cpu与逻辑cpu概述(本博客属于转载部分内容:主要学习目的用于大数据平台Hadoop之yarn资源调度的配置) 一.yarn资源调度器中主要的资源分类       1.memory(内存) 2. ...

  5. Apache2.4更改默认根目录并配置虚拟域名

    软件环境: 1.virtualbox中安装Ubuntu 16.04-server 2.window7下安装Xshell5 以上安装好后, 1.设置virtualbox网络为桥接网卡,启动Ubuntu. ...

  6. _markupbase.py if not match: UnboundLocalError: local variable 'match' referenced before assignment,分析Python 库 html.parser 中存在的一个解析BUG

    BUG触发时的完整报错内容(本地无关路径用已经用 **** 隐去): **************\lib\site-packages\bs4\builder\_htmlparser.py:78: U ...

  7. oculus network error ovr53225466

    最近调试oculus,搬运代码到win10平台,发现最近FB对oculus的服务程序进行了更新,必须要登陆账号才能进行调试. 于是安装oculusclient,但是登陆的过程中出现了问题,如果不用代理 ...

  8. 【例题 4-4 uva 213】Message Decoding

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 输入的二进制长度最长为7 所以得开个sta[7][2^7]的样子才存的下所有的字符的.. 定义这么一个数组当字典. 然后一个字符一个 ...

  9. [SDOI2008]沙拉公主的困惑 线性筛 素数+欧拉

    本文为博主原创文章,欢迎转载,请注明出处 www.cnblogs.com/yangyaojia [SDOI2008]沙拉公主的困惑 线性筛 素数+欧拉 题目大意 给定n,m,求在1到n!内与m!互质的 ...

  10. Python - 字符串模板的安全替换(safe_substitute) 具体解释

    字符串模板的安全替换(safe_substitute) 具体解释 本文地址: http://blog.csdn.net/caroline_wendy/article/details/27057339 ...