C语言
2025-06-30 10:17:06
发布于:浙江
8阅读
0回复
0点赞
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 5000
#define MAX_M 5000
#define MAX_A 100000
int main() {
int n, m;
scanf("%d %d", &n, &m);
if (n == 0) {
printf("0\n");
return 0;
}
char hash[MAX_A + 1] = {0};
for (int j = 0; j < m; j++) {
int a;
scanf("%d", &a);
hash[a] = 1;
}
for (int i = 1; i < n; i++) {
char temp_hash[MAX_A + 1] = {0};
int count = 0;
for (int j = 0; j < m; j++) {
int a;
scanf("%d", &a);
if (hash[a]) {
temp_hash[a] = 1;
count++;
}
}
if (count == 0) {
printf("0\n");
return 0;
}
for (int k = 0; k <= MAX_A; k++) {
hash[k] = temp_hash[k];
}
}
int result = 0;
for (int k = 0; k <= MAX_A; k++) {
result += hash[k];
}
printf("%d\n", result);
return 0;
}
这里空空如也
有帮助,赞一个