Codeforces 231A.Team(brute force, greedy)

Posted 晴空๓

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces 231A.Team(brute force, greedy)相关的知识,希望对你有一定的参考价值。

上一篇博客:第十二届蓝桥杯省赛第一场C/C++ B组真题及部分题解

 写在前面:大家好!我是晴空๓。如果博客中有不足或者的错误的地方欢迎在评论区或者私信我指正,感谢大家的不吝赐教。我的唯一博客更新地址是:https://ac-fun.blog.csdn.net/。非常感谢大家的支持。一起加油,冲鸭!
用知识改变命运,用知识成就未来!加油 (ง •̀o•́)ง (ง •̀o•́)ง

原题链接:Codeforces 231A.Team

文章目录

The title information

Problem description

 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. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, 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.

Examples

input one

3
1 1 0
1 1 1
1 0 0

output one

2

input two

2
1 0 0
0 1 1

output two

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.

Answer

The title mean

 题目大概的意思是三个同学组队参加 ACM,只有当两个或者两个以上同学确定他们的题目可以 Accepted 的时候他们才会提交题目。问最后他们一共会提交几次题目。输入一个字母 n 表示比赛一共有几道题目,接下来的 n 行输入 n 条数据,没条数据一次表示三位同学是否确定他们的题目可以 Accepted,如果为 1 表示确定,0 表示不确定。最后输出正常比赛他们确定提交几道题目。

Ideas

 因为题目的数据范围比较小,所以可以直接边输入边统计,最后输出结果即可。

AC code

#include<iostream>
#include<cstdio>

using namespace std;
int n, ans;

int main() 
	cin >> n;
	for (int i = 0; i < n; i++) 
		int a, b, c, cnt = 0;
		cin >> a >> b >> c;
		if (a) cnt++;
		if (b) cnt++;
		if (c) cnt++;
		if (cnt >= 2) ans++;
	
	cout << ans;
	return 0;


未完待续,持续更新中……

以上是关于Codeforces 231A.Team(brute force, greedy)的主要内容,如果未能解决你的问题,请参考以下文章

CodeForces - 231A Team水题

如何修复 brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = -107374

Codeforces 231CTo Add or Not to Add

Codeforces Round #231 (Div. 2) E.Lightbulb for Minister

Codeforces231 C. To Add or Not to Add(贪心,双指针)

Exception in thread "main" brut.androlib.AndrolibException: Could not decode arsc file at