当前位置:网站首页>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;
}
边栏推荐
- Marubeni Baidu applet detailed configuration tutorial, approved.
- El tree whether leaf node or not, the drop-down button is permanent
- Machine learning experiment report 1 - linear model, decision tree, neural network part
- Qrcode: generate QR code from text
- Pytest (4) - test case execution sequence
- Returns the lowest common ancestor of two nodes in a binary tree
- Design and practice of kubernetes cluster and application monitoring scheme
- Hmi-31- [motion mode] solve the problem of picture display of music module
- Hmi-32- [motion mode] add light panel and basic information column
- [Yu Yue education] National Open University autumn 2018 8109-22t (1) monetary and banking reference questions
猜你喜欢
Sqoop安装
端口,域名,协议。
Idea inheritance relationship
Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles
Design and implementation of high availability website architecture
Port, domain name, protocol.
Why are there fewer and fewer good products produced by big Internet companies such as Tencent and Alibaba?
Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 1)
Design and implementation of campus epidemic prevention and control system based on SSM
Hmi-30- [motion mode] the module on the right side of the instrument starts to write
随机推荐
When the low alcohol race track enters the reshuffle period, how can the new brand break the three major problems?
Zabbix
Day_ 17 IO stream file class
Machine learning experiment report 1 - linear model, decision tree, neural network part
LeetCode 314. Binary tree vertical order traversal - Binary Tree Series Question 6
Scientific research: are women better than men?
问下,这个ADB mysql支持sqlserver吗?
Voice chip wt2003h4 B008 single chip to realize the quick design of intelligent doorbell scheme
[daily problem insight] Li Kou - the 280th weekly match (I really didn't know it could be so simple to solve other people's problems)
Tencent cloud, realize image upload
有个疑问 flink sql cdc 的话可以设置并行度么, 并行度大于1会有顺序问题吧?
Flume configuration 4 - customize mysqlsource
Share the newly released web application development framework based on blazor Technology
Azkaban actual combat
LeetCode146. LRU cache
2. Common request methods
Design and practice of kubernetes cluster and application monitoring scheme
Comparison of advantages and disadvantages between platform entry and independent deployment
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience
1.五层网络模型