Codeforces 231 A Team (water problem)

Source: Internet
Author: User
Tags time limit
A. Team Click to open
Time limit per test 2 seconds memory limit per test megabytes input standard input output standard output

One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants is usually offered several problems during programming contests. Long before the start the friends decided that they would implement a problem if at least both of them is sure about the so Lution. Otherwise, the friends won ' t write the problem ' s solution.

This contest offers n problems to the participants. For each problem we know, which friend was sure about the solution. Help the Friends find the number of problems for which they would write a solution. Input

The first input line contains a single integer n (1≤n≤1000)-the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1 and then Petya was sure about the problem ' s solution, otherwise he isn ' t sure. The second number shows Vasya ' s view on the solution, the third number shows Tonya ' s view. The numbers on the lines is separated by spaces. Output

Print a single integer-the number of problems the friends would implement on the contest. Sample Test (s) input

3
1 1 0
1 1 1
1 0 0
Output
2
Input
2
1 0 0
0 1 1
Output
1
Note

In the first sample Petya and Vasya is sure that they know what to solve the first problem and all three of them know how To solve the second problem. That's means that they would write solutions for these problems. Only Petya are sure about the solution for the third problem, but that isn ' t enough, so the friends won ' t take it.

In the second sample the friends would only implement the second problem, as Vasya and Tonya is sure about the solution.

Code:

#include <iostream>
using namespace std;
int main ()
{
    int n,s,ans,a[4],i;
    while (Cin>>n)
    {
        s=0;
        while (n--)
        {
            ans=0;
            for (i=0;i<3;i++)
            {
                cin>>a[i];
                if (a[i]==1)
                    ans++;
            }
            if (ans>=2)
                s++;
        }
        cout<<s<<endl;
    }
    return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.