3 1 0 1 0 1 0 1 0 1
1 3
已知好芯片比坏芯片多,因此测试为好次数最多的芯片必是好芯片
找出被测试为好次数最多的芯片,此芯片的测试数据必准确,输出此芯片的测试数据即可。
1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 #include <string> 5 #include <math.h> 6 #include <algorithm> 7 #include <vector> 8 #include <stack> 9 #include <queue> 10 #include <set> 11 #include <map> 12 #include <sstream> 13 const int INF=0x3f3f3f3f; 14 typedef long long LL; 15 const double eps =1e-8; 16 const int mod=1e9+7; 17 const int maxn=1e6+10; 18 using namespace std; 19 20 int G[25][25]; 21 22 int main() 23 { 24 #ifdef DEBUG 25 freopen("sample.txt","r",stdin); 26 #endif 27 28 int n; 29 scanf("%d",&n); 30 for(int i=1;i<=n;i++) 31 { 32 for(int j=1;j<=n;j++) 33 scanf("%d",&G[i][j]); 34 } 35 int id; 36 int MAX=0; 37 for(int i=1;i<=n;i++) 38 { 39 int num=0; 40 for(int j=1;j<=n;j++) 41 { 42 if(i!=j&&G[i][j]) num++; 43 } 44 if(num>MAX) 45 { 46 MAX=num; 47 id=i; 48 } 49 } 50 int flag=0; 51 for(int i=1;i<=n;i++) 52 { 53 if(G[id][i]) 54 { 55 printf(flag==0?"%d":" %d",i); 56 flag=1; 57 } 58 } 59 60 return 0; 61 }
-
原文:https://www.cnblogs.com/jiamian/p/12317847.html