codeforces 231A Team
来源:互联网 发布:淘宝销量多久更新一次 编辑:程序博客网 时间:2024/05/29 14:50
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.
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.
Print a single integer — the number of problems the friends will implement on the contest.
31 1 01 1 11 0 0
2
21 0 00 1 1
1
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.
AC:
#include<bits/stdc++.h>
using namespace std;
struct nd
{
int x,y,z;
}p[1010];
int main()
{
int t,ans;
ans=0;
cin>>t;
for(int i=0;i<t;i++)
cin>>p[i].x>>p[i].y>>p[i].z;
for(int i=0;i<t;i++)
if((p[i].x==1&&p[i].y==1&&p[i].z==1)||
(p[i].x==0&&p[i].y==1&&p[i].z==1)||
(p[i].x==1&&p[i].y==0&&p[i].z==1)||
(p[i].x==1&&p[i].y==1&&p[i].z==0))
ans++;
cout<<ans<<endl;
}
- codeforces 231A Team
- codeforces 231 A Team(水题)
- Problem--231A--Codeforces--Team
- CodeForces 231 A.Team(水~)
- 【CODEFORCES】 A. Team Olympiad
- CodeForces 490A Team Olympiad
- Codeforces Round #143 (Div. 2) / 231A Team (模拟)
- Codeforces #279 A Team Olympiad 瞎搞
- Codeforces 490A Team Olympiad(水)
- 231A - Team
- 231A Team
- CF 231A team
- Codeforces Round #279 (Div. 2)---A. Team Olympiad (贪心)
- Codeforces Round #279 (Div. 2) A. Team Olympiad
- Codeforces-519C-A and B and Team Training
- codeforces—— 490A —— Team Olympiad
- codeforces 519C A and B and Team Training
- A. Team
- 《算法4》最小生成树之Prim与Kruskal算法
- 最高频IP
- 类名.this
- 10. Leaders
- quint16转换成QString
- codeforces 231A Team
- 【CSS】CSS选择器的妙用,学会你就不用js了。
- Ubuntu17.04安装和卸载mongodb
- 数据都存放在哪些区
- JAVA swing组件一些修饰方法
- 474. Ones and Zeroes
- 淘淘商城实战高并发分布式项目(2016.8月新版)
- js判断数组为空
- 兑换硬币(简单版,枚举)