codeforces 69A Young Physicist
来源:互联网 发布:联通网络报修电话 编辑:程序博客网 时间:2024/05/22 12:54
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.
The first line contains a positive integer n (1 ≤ n ≤ 100), then follown lines containing three integers each: thexi coordinate, theyi coordinate and thezi coordinate of the force vector, applied to the body ( - 100 ≤ xi, yi, zi ≤ 100).
Print the word "YES" if the body is in equilibrium, or the word "NO" if it is not.
34 1 7-2 4 -11 -5 -3
NO
33 -1 7-5 2 -42 -1 -3
YES
AC:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int x[110],y[110],z[110],sum[110];
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d%d%d",x+i,y+i,z+i);
int ans1=0,ans2=0,ans3=0;
for(int i=0;i<n;i++)
ans1+=x[i];
for(int i=0;i<n;i++)
ans2+=y[i];
for(int i=0;i<n;i++)
ans3+=z[i];
if(ans1==0&&ans2==0&&ans3==0)
printf("YES\n");
else
printf("NO\n");
}
- codeforces 69A Young Physicist
- codeforces 69A(Young Physicist) Java
- 69A - Young Physicist
- Codeforces Young Physicist
- A. Young Physicist
- 【水】#63 A. Young Physicist
- Search a Young Tableau
- codeforces 14B. Young Photographer
- CodeForces 14B Young Photographer
- Letter to a Young Developer
- Letter to a Young Developer
- Letter to a Young Developer
- Codeforces--237B--Young Table(模拟)
- Codeforces 237B Young Table 【构造】
- CodeForces - 237B Young Table (模拟)
- A physicist, an engineer, and a computer scientist discussing the nature of God.
- Advice to a Young Man(enjoy it)
- When I was a young man
- 随机森林random forest及python实现
- triplet loss (原理 + 实现)
- java finalize方法总结、GC执行finalize的过程
- 微信公众号支付爬坑总结
- 【SSH网上商城】问题是老大
- codeforces 69A Young Physicist
- 堆和栈的区别
- 航空遥感图像(Aerial Images)目标检测数据集汇总
- C++ Vector遍历的几种方式()
- 程序编译-汇编-链接的理解04-可执行文件概述
- vue之项目目录设计
- cpu之register
- mongodb基础语法(增删改查)
- Android性能细节优化之---字符串连接篇