首页 > 编程语言 >算法战斗第二天C++1

算法战斗第二天C++1

时间:2023-12-13 20:11:30浏览次数:27  
标签:sure number problems 第二天 C++ solution 算法 problem friends

A. Team

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
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.

三个人举手表决大于半票就通过,调了半天都不通过,居然因为累加值没有初始化。。。心态崩了,真绝

#include<iostream>
using namespace std;

int main(){
	int n,a,b,c,action=0;
	cin>>n;
	while(n-- && 1<=n<=1000){
		cin>>a>>b>>c;
		if((a+b+c)>1 && (a==0|1) && (b==0|1) && (c==0|1)){
			action++;
		}		
	}
	cout<<action<<endl; 	
	return 0;
} 

 

标签:sure,number,problems,第二天,C++,solution,算法,problem,friends
From: https://www.cnblogs.com/AlbertKs220111/p/17899827.html

相关文章

  • 代码随想录算法训练营第一天| LeetCode704 二分查找、27移除元素
     Leetcode704:二分查找今日学习的文章链接:代码随想录(programmercarl.com) 题目链接:704.二分查找-力扣(LeetCode)●  自己看到题目的第一想法这题我会,但是还没明白卡尔说的循环不变量是什么意思。我的固定思路就是,target比中间值大,左指针右移到mid+1;target比中间值......
  • 百度 推荐 投的cpp开发 不知道怎么给的推荐算法的岗位
    判断(){}是否合法?多线程通信方式手段?成员函数模板 类模板智能指针底层原理为什么引入linux文本定位到最后一行vi进入之后:$定位到最后一行  一、使用cat、tail、head组合1、查看最后100行的数据 catfilename|tail-n1002、查看100到300行的数据 cat......
  • C++ 析构函数 virtual 虚析构
    结论:当父类存在virtual函数时,则需要实现虚析构函数。直接上代码:#include<iostream>#include<memory>classAAA{public:AAA(){printf("AAA构造...\n");}//virtual~AAA(){printf("AAA析构...\n");}virtualvoidSayOk()=0;};cl......
  • 算法学习Day1,二分查找,移除元素
    Day1二分查找,移除元素ByHQWQF2023/12/13笔记704.二分查找给定一个n个元素有序的(升序)整型数组nums和一个目标值target,写一个函数搜索nums中的target,如果目标值存在返回下标,否则返回-1。解法:使用二分查找来在一个有序的数组中找到指定元素的下标。根据数据边界......
  • TSINGSEE青犀基于opencv的安全帽/反光衣/工作服AI检测算法自动识别及应用
    安全帽/反光衣/工作服自动识别检测算法可以通过opencv+yolo网络对现场画面中人员穿戴着装进行实时分析检测,判断人员是否穿着反光衣/安全帽。在应用场景中,安全帽/反光衣/工作服检测应用十分重要,通过对人员的规范着装进行实时监测与预警,可以降低安全隐患,提高安全性。Tips:OpenCV......
  • MyBatis-Plus雪花算法实现源码解析
    1.雪花算法(SnowflakeAlgorithm)雪花算法(SnowflakeAlgorithm)是一种用于生成唯一标识符(ID)的分布式算法。最初由Twitter公司开发,用于生成其内部分布式系统中的唯一ID。雪花算法的设计目标是在分布式系统中生成全局唯一的ID,同时保证ID的有序性和趋势递增。雪花算法生成的ID是64......
  • C++ Qt开发:CheckBox多选框组件
    Qt是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍CheckBox单行输入框组件的常用方法及灵活运用。QCheckBox是Qt中用于实现复选框的组件,它提供了......
  • 嵌入式图像处理:算法、应用与性能优化
    嵌入式系统在现代科技中扮演着重要的角色,广泛应用于医疗设备、汽车、工业控制、智能家居等领域。嵌入式图像处理作为其中的一个关键组成部分,为许多应用提供了视觉感知能力。本文将介绍嵌入式图像处理的算法、应用以及性能优化方法,并提供相关的代码示例。嵌入式图像处理算法图像采集......
  • C++类的静态成员
    C++类的静态成员声明并使用静态成员使用static关键字将其与类关联在一块,同样,static声明的对象也可以声明访问权限public,private注意,类的静态成员存在于任何对象之外,对象中不包含任何与静态数据有关的数据,就是说类中声明的静态成员是独立于类而存在的,只是和类相关联(这里的独立并不......
  • 羚通视频智能分析平台烟火检测与烟火识别算法的深度解析
    随着科技的不断发展,人工智能技术在各个领域的应用越来越广泛。其中,视频智能分析技术以其高效、准确的特点,被广泛应用于安全防护、环境监测等多个领域。今天,我们将重点介绍羚通视频智能分析平台中的烟火检测、烟火识别算法。一、烟火检测的重要性烟火检测是公共安全的重要环节,它能......