C - Young Physicist
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的更多相关文章
- codeforces水题100道 第九题 Codeforces Beta Round #63 (Div. 2) Young Physicist (math)
题目链接:http://www.codeforces.com/problemset/problem/69/A题意:给你n个三维空间矢量,求这n个矢量的矢量和是否为零.C++代码: #include & ...
- codeforcess水题100道
之所以在codeforces上找这100道水题的原因是为了巩固我对最近学的编程语言的掌握程度. 找的方式在codeforces上的PROBLEMSET中过的题最多的那些题里面出现的最前面的10个题型, ...
- 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 ...
- 斯考特·杨(Scott Young)快速学习方法
上午在网上看到了斯考特·杨(Scott Young)的快速学习方法,感觉很受鼓舞. 现在已经读研究生了,可是发现自己自从上大学以来到现在,发现自己的学习方法有很大的问题. 我是个特别喜欢读书的人,在大 ...
- Young氏矩阵
一个 m x n 的Young氏矩阵是指,每一行数据都是从左到右排好序,每一列的数据也都是从上到下排好序.其中也可能存在一些INF的数据,表示不存在的元素,一个mxn的Young氏矩阵最多用来存放 r ...
- ural 1157. Young Tiler
1157. Young Tiler Time limit: 1.0 secondMemory limit: 64 MB One young boy had many-many identical sq ...
- 算法导论 第六章 思考题6-3 Young氏矩阵
这题利用二叉堆维持堆性质的办法来维持Young氏矩阵的性质,题目提示中写得很清楚,不过确实容易转不过弯来. a,b两问很简单.直接看c小问: 按照Young氏矩阵的性质,最小值肯定在左上角取得,问题在 ...
- 【杨氏矩阵+勾长公式】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 ...
- The Sorrows of Young Werther
The Sorrows of Young Werther J.W. von Goethe Thomas Carlyle and R.D. Boylan Edited by Nathen Haskell ...
随机推荐
- 【Bootstrap】如何让响应式图片(img-responsive)水平居中
我们在用bootstrap排版内容的时候,有的时候在内容中需要图片水平居中对齐. 一般情况下,我们的图片都使用了 .img-responsive 类来实现响应式图片.如果需要实现响应式图片水平居中,那 ...
- Python2X和Python3X 除法运算符的使用:
首先注明:如果没有特别说明,以下内容都是基于python 3.4的. 1. /是精确除法,//是向下取整除法,%是求模 2. %求模是基于向下取整除法规则的 3. 四舍五入取整round, 向零取整i ...
- 聚合函数与SQL排序
聚合查询 通过SQL对数据进行某种操作或计算时需要使用函数(聚合函数,将多行汇为一行). 常用函数(5个): COUNT:计算表中的记录数(行数) SUM: 计算表中数值列中数据的合计值 AVG: 计 ...
- Uoj #274. 【清华集训2016】温暖会指引我们前行 LCT维护边权_动态最小生成树
Code: 行#include<bits/stdc++.h> #define ll long long #define maxn 1000000 #define inf 100000000 ...
- package、folder和source folder的区别
在用myeclipse工具开发java的过程中,新建目录时发现会有package,folder和source folder等不同类型的选项, 因此在网上搜集了一些资料:如下 以下文章转自:https: ...
- Mysql [Err] 1118 - Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535.
对于越来越多的数据,数据库的容量越来越大,压缩也就越来越常见了.在我的实际工作中进行过多次压缩工作,也遇到多次问题,在此和大家分享一下. 首先,我们先说说怎么使用innodb的压缩. 第一,mysql ...
- 37.query string、_all metadata
主要知识点 1.query string基础语法 2._all metadata的理解 一.query string基础语法 1.GET /test_index/test_type/_sear ...
- 用JMeter作WebService接口功能测试(可以借助SoapUI来完成)
SoapUI里面的操作: Wsdl文件或链接导入或添加到SoapUI打开待测请求:运行请求:取URL SOAPAction .报文. JMeter里面的操作: 为线程组添加SOAP/XML-RPC ...
- 0808关于RDS如何恢复到本地教程
转自http://www.cnblogs.com/ilanni/archive/2016/02/25/5218129.html 公司目前使用的数据库是阿里云的RDS,目前RDS的版本为mysql5.6 ...
- 导致“mysql has gone away”的两种情况
导致“mysql has gone away”的两种情况 By Cruise 1. wait_timeout参数 在开发代理server时, 我使用了jdbc连接数据库,并采用长连接的方式连接数据库 ...