当前位置:网站首页>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;
}
边栏推荐
- 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
- IPv6 experiment
- Single box check box
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
- Character painting, I use characters to draw a Bing Dwen Dwen
- Why do you understand a16z? Those who prefer Web3.0 Privacy Infrastructure: nym
- This + closure + scope interview question
- There is a question about whether the parallelism can be set for Flink SQL CDC. If the parallelism is greater than 1, will there be a sequence problem?
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
- Dart series: collection of best practices
猜你喜欢

Mongodb common commands
![[uc/os-iii] chapter 1.2.3.4 understanding RTOS](/img/33/1d94583a834060cc31cab36db09d6e.jpg)
[uc/os-iii] chapter 1.2.3.4 understanding RTOS

Anchor free series network yolox source code line by line explanation Part 2 (a total of 10, ensure to explain line by line, after reading, you can change the network at will, not just as a participan

丸子百度小程序详细配置教程,审核通过。

1. Five layer network model

【LeetCode】404. Sum of left leaves (2 brushes of wrong questions)

2021 Li Hongyi machine learning (3): what if neural network training fails

Scientific research: are women better than men?

The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety

Pat grade a 1119 pre- and post order traversals (30 points)
随机推荐
Azkaban installation and deployment
Design and implementation of campus epidemic prevention and control system based on SSM
【LeetCode】222. The number of nodes of a complete binary tree (2 mistakes)
Azkaban实战
端口,域名,协议。
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
Blue bridge - maximum common divisor and minimum common multiple
Design and practice of kubernetes cluster and application monitoring scheme
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
Character painting, I use characters to draw a Bing Dwen Dwen
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
Linux安装Redis
ELK日志分析系统
LeetCode146. LRU cache
openresty ngx_ Lua execution phase
Good documentation
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience
Bumblebee: build, deliver, and run ebpf programs smoothly like silk
返回二叉树中两个节点的最低公共祖先