当前位置:网站首页>001 chip test
001 chip test
2022-07-05 02:58:00 【Hidden clouds and fog】
Problem description
Yes n(2≤n≤20) Chip chip , There are good and bad , We know that there are more good chips than bad ones .
Each chip can be used to test other chips . When using the chip to test other chips , Whether the chip under test is good or bad can be given correctly . When testing other chips with bad chips , Will randomly give good or bad test results ( That is, this result has nothing to do with the actual quality of the chip being tested ).
Give the test results of all chips , Ask which chips are good .
Input format
The first line of input data is an integer n, Number of chips .
Line two to line two n+1 Behavior n*n A watch of , Each row n Data . Each data in the table is 0 or 1, Here n The first in the line i Xing di j Column (1≤i, j≤n) The data of is represented by No i Block chip test j The test results obtained when the chip is block ,1 Say good ,0 Means bad ,i=j All the time 1( It does not mean the test result of the chip on itself . The chip cannot test itself ).
Output format
Output all good chip numbers from small to large
The sample input
3
1 0 1
0 1 0
1 0 1
Sample output
1 3
Code
# Ideas : Because there are more good chips than bad ones , So when each chip is compared with other chips ,
# As long as the test result is greater than or equal to n/2 It can prove that this is a good chip , Then input the location of the chip .
#include<iostream>
#include<stdio.h>
using namespace std;
int a[100][100];
int main()
{
int n;
cin>>n;
for(int i = 0;i<n;i++)
{
for(int j = 0;j<n;j++)
{
cin>>a[i][j];
}
}
int b[100];
for(int i=0;i<n;i++)
{
int sum = 0;
for(int j = 0;j<n;j++)
{
if(a[j][i]==1)
sum++;
}
b[i] = sum;
}
for(int i = 0;i<n;i++)
{
if(b[i]-1>=n/2)
cout<<i+1<<" ";
}
cout<<endl;
return 0;
}
边栏推荐
- Six stone programming: advantages of automated testing
- Design of kindergarten real-time monitoring and control system
- Good documentation
- 返回二叉树中两个节点的最低公共祖先
- Problem solving: attributeerror: 'nonetype' object has no attribute 'append‘
- Avoid material "minefields"! Play with super high conversion rate
- Sqoop命令
- 看 TDengine 社区英雄线上发布会,听 TD Hero 聊开发者传奇故事
- Returns the lowest common ancestor of two nodes in a binary tree
- 问下,这个ADB mysql支持sqlserver吗?
猜你喜欢

腾讯云,实现图片上传

Design and practice of kubernetes cluster and application monitoring scheme

College Students' innovation project management system

Sqoop command

Single box check box

Three line by line explanations of the source code of anchor free series network yolox (a total of ten articles, which are guaranteed to be explained line by line. After reading it, you can change the

ELFK部署
![Hmi-30- [motion mode] the module on the right side of the instrument starts to write](/img/6b/09bb8fd95b707a459534eaeb72eb59.jpg)
Hmi-30- [motion mode] the module on the right side of the instrument starts to write
![Hmi-31- [motion mode] solve the problem of picture display of music module](/img/9c/0b25c0a41758652848aed2a269880f.jpg)
Hmi-31- [motion mode] solve the problem of picture display of music module

Azkaban overview
随机推荐
Qrcode: generate QR code from text
Three line by line explanations of the source code of anchor free series network yolox (a total of ten articles, which are guaranteed to be explained line by line. After reading it, you can change the
College Students' innovation project management system
Single box check box
Elk log analysis system
Asp+access campus network goods trading platform
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
Spoon inserts and updates the Oracle database, and some prompts are inserted with errors. Assertion botch: negative time
Apache Web page security optimization
打破信息茧房-我主动获取信息的方法 -#3
Marubeni Baidu applet detailed configuration tutorial, approved.
返回二叉树中两个节点的最低公共祖先
Openresty ngx Lua Execution stage
Devtools的簡單使用
Comparison of advantages and disadvantages between platform entry and independent deployment
丸子百度小程序详细配置教程,审核通过。
Character painting, I use characters to draw a Bing Dwen Dwen
Utilisation simple de devtools
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
【LeetCode】111. Minimum depth of binary tree (2 brushes of wrong questions)