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 ;
}

最新文章

  1. jQ获取浏览器window的高宽
  2. Java Hour 35 Weather ( 8 ) struts2 &ndash; message resource
  3. 利用while(code!=EOF){}来实现“无限”循环
  4. Mysql Workbench 学习
  5. 让你了解x86的中断
  6. sql 自定义函数-16进制转10进制
  7. Entity Framework中查看生成的SQL语句
  8. 10071 - Back to High School Physics
  9. poj 3608 旋转卡壳求不相交凸包最近距离;
  10. 用c++编写一个不能被继承的类(但是可以在类外部定义该类的对象)
  11. Spring五个事务隔离级别和七个事务传播行为
  12. 剑指offer面试题5 从头到尾打印链表(c)
  13. 国际化之Android设备支持的语种
  14. linux学习第十二天 (Linux就该这么学)找到一本不错的Linux电子书,附《Linux就该这么学》章节目录
  15. Sprint第三个计划
  16. (转)Eclipse配置GitHub代码库(以Windows7为例)
  17. Android分享到微信和朋友圈的工具类
  18. Docker-compose部署gitlab中文版
  19. mysq 数据库基本管理
  20. oracle 11g自动时间分区备忘

热门文章

  1. java Web(4)
  2. (转)Arcgis for JS之对象捕捉
  3. centos7 删除libc.so.6 紧急救援
  4. BZOJ 1426: 收集邮票 数学期望 + DP
  5. 基于MATLAB的语音信号处理
  6. 定位IO瓶颈的方法,iowait低,IO就没有到瓶颈?
  7. [frontend] 根据文字长度 自适应宽度 自适应高度+ Uncaught ReferenceError: xxx is not defined at HTMLDivElement.onclick
  8. 函数(day08)
  9. 单行函数、表连接(day02)
  10. Jquery-自定义表单验证