Codeforces 69-A problem solution

A. Young Physicist
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.

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

Solution
  • [tab]
    • C++
      • #include<iostream>
        using namespace std;
         
        int main()
        {
            int n,x,y,z,sum1=0,sum2=0,sum3=0;
            cin>>n;
         
            while(n--)
            {
                cin>>x>>y>>z;
                sum1+=x;
                sum2+=y;
                sum3+=z;
            }
                if(sum1==0 && sum2==0 && sum3==0)
                {
                    cout<<"YES"<<endl;
                
            else{
                cout<<"NO"<<endl;
            }
            return 0;
        }
        


3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: Codeforces 69-A problem solution
Codeforces 69-A problem solution
DorHubs
https://dorhubs.blogspot.com/2019/07/codeforces-69-problem-solution.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2019/07/codeforces-69-problem-solution.html
true
9087637800571592252
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy