现在的位置: 首页 > 综合 > 正文

CF231A Team

2013年09月19日 ⁄ 综合 ⁄ 共 1850字 ⁄ 字号 评论关闭
time limit per test

2 seconds

memory limit per test

256 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 are usually offered several problems during programming contests. Long before the start the friends
decided that they will implement a problem if at least two of them are sure about the solution. 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 is sure about the solution. Help the friends find the number of problems for which they will write
a solution.

Input

The first input line contains a single integer
n
(1 ≤ n ≤ 1000) — the number of problems in the contest. Thenn lines contain three integers each, each integer is either0 or
1. If the first number in the line equals1, then Petya is 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 are separated by spaces.

Output

Print a single integer — the number of problems the friends will 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 are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is
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 will only implement the second problem, as Vasya and Tonya are sure about the solution.

解题思路:该题为简单题,读懂题目即可解得。

对于每一组输入数据,每个题目的输入值,如果3个值相加大于等于2,该题可做,统计总数的变量加1即可。

本题有问题的一般是ACM刚入门的孩子。要注意以下几点:

1、输入数据有多组,记得遇到文件结束标志时下结束输入while(scanf("%d",&n)!=EOF)。

2、测试数据中,每个题目的输入时,输入格式提示中不要加”,“,末尾不要加”\n“。

3、对于每组测试数据,记得要把计数的变量初始化为0,否则会造成答案错误。



#include<stdio.h>
int main()
{
    int x,y,z;
    int n,sum;
    while(scanf("%d",&n)!=EOF)
    {
        sum=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d%d%d",&x,&y,&z);
            sum+=x+y+z>=2?1:0;
        }
        printf("%d\n",sum);
    }
    return 0;
}

抱歉!评论已关闭.