当前位置: 首页 > 工具软件 > Young > 使用案例 >

A. Young Physicist

云洋
2023-12-01

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 yicoordinate and the zi coordinate 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.

Sample test(s)
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


解题说明:此题就是统计每一列数字之和是否为0,水题

#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

int main()
{
	int n,i;
	int sum1,sum2,sum3;
	int a[101],b[101],c[101];
	scanf("%d",&n);
	sum1=0;
	sum2=0;
	sum3=0;
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		sum1+=a[i];
		sum2+=b[i];
		sum3+=c[i];
	}
	if(sum1==0&&sum2==0&&sum3==0)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}


 类似资料:

相关阅读

相关文章

相关问答