Codeforces Round #143 (Div. 2) A. Team

http://codeforces.com/problemset/problem/231/A

题意:3个人去参加比赛,如果有2个人会做,则这道题他们得分。问他们会得多少分。

PS:
有一个问题,如果输入的不是0和1可能会出错。
所以,判断是否有2个为1更严谨。(当然题目已经说了只会输入0和1)

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <bits/stdc++.h>
using namespace std;

int main() {
int n, a, b, c, cnt = 0;
cin >> n;
while (n--) {
cin >> a >> b >> c;
if ((a + b + c) >= 2) cnt++;
}
cout << cnt;
return 0;
};