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. Python3编写自动签到服务程序

    公司加班的餐补需要登录网站签到领取,有时候会忘记,于是自己用Python写了小程序来自动签到.刚开始只是做了自己用,直接写的黑框程序,后来给同事用,就打包成exe.再后来有人说要写成window服务会 ...

  2. 2、scala条件控制与循环

    1.  if表达式 2.  句终结符.块表达式 3.  输入与输出 4.  循环 5.  高级for循环 1.  if表达式 if表达式的定义:scala中,表达式是有值的,就是if或者else中最后 ...

  3. 查看占用某端口的进程——netstat、findstr 的使用

    netstat   检验本机各端口的网络连接情况 -a 显示所有连接和侦听端口(如Windows共享服务 的135,445端口) -n 不进行IP地址到主机名的解析 -o 显示拥有的与每个连接关联的进 ...

  4. style 使用lang = ‘scss’ 报错

    <style lang="scss" rel="stylesheet/scss" scoped> .export-wrapper{ } </s ...

  5. redis客户端连接到服务器的步骤

    和大多数客户端连接到服务器一样,redis-cli连接到服务器也主要分为两个阶段,请求连接阶段和数据传送阶段.具体来讲redis-cli做的事情有: 1.以socket方式建立连接: 2,选择相应的数 ...

  6. Spring Cloud Alibaba、Spring Boot、Spring Cloud对应版本关系

    Spring Boot Spring Cloud Spring Cloud Alibaba 2.1.x Greenwich 0.9.x 2.0.x Finchley 0.2.x 1.5.x Edgwa ...

  7. HDU 5729 Rigid Frameworks (联通块计数问题)

    题目传送门 通过看题解画图可以发现: 不论怎么转,一列里的横边/一行里的竖边始终平行 当我们加固一个格子时,会让它所在的这一行的竖边和这一列的横边保证垂直 而我们的目标是求所有竖边和横边都保证垂直的方 ...

  8. 域名IP绑定

    该文为阿里云域名举例 首先具备3个前提: 买服务器并搭建环境:阿里云官网购买阿里云的服务器(我购买的是window系统,ECS服务器). 在自己的云服务器上布置上jdk,配置环境变量:安装上tomca ...

  9. 5、SpringBoot+MyBaits+Maven+Idea+pagehelper分页插件

    1.为了我们平时方便开发,我们可以在同一个idea窗口创建多个项目模块,创建方式如下 2.项目中pom.xm文件的内容如下 <?xml version="1.0" encod ...

  10. Codeforces 525E Anya and Cubes 中途相遇法

    题目链接:点击打开链接 题意: 给定n个数.k个感叹号,常数S 以下给出这n个数. 目标: 随意给当中一些数变成阶乘.至多变k个. 再随意取一些数,使得这些数和恰好为S 问有多少方法. 思路: 三进制 ...