当前位置:网站首页>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;
}
边栏推荐
- El tree whether leaf node or not, the drop-down button is permanent
- Spark SQL learning bullet 2
- Day_ 17 IO stream file class
- d3js小记
- [Yu Yue education] National Open University spring 2019 0505-22t basic nursing reference questions
- Azkaban overview
- Watch the online press conference of tdengine community heroes and listen to TD hero talk about the legend of developers
- Six stone programming: advantages of automated testing
- El select, El option drop-down selection box
- Utilisation simple de devtools
猜你喜欢
Acwing game 58 [End]
IPv6 experiment
Azkaban实战
SQL injection exercise -- sqli Labs
Hmi-32- [motion mode] add light panel and basic information column
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
Moco V2 literature research [self supervised learning]
Elfk deployment
ELK日志分析系统
随机推荐
Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
Acwing game 58 [End]
Design and implementation of kindergarten management system
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
SQL performance optimization skills
Why is this an undefined behavior- Why is this an undefined behavior?
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience
【LeetCode】501. Mode in binary search tree (2 wrong questions)
Sqoop安装
Cut! 39 year old Ali P9, saved 150million
Qrcode: generate QR code from text
1. Five layer network model
This + closure + scope interview question
Port, domain name, protocol.
数据库和充值都没有了
Avoid material "minefields"! Play with super high conversion rate
D3js notes
openresty ngx_lua变量操作
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience
When the low alcohol race track enters the reshuffle period, how can the new brand break the three major problems?