题目链接:https://www.luogu.com.cn/problem/P1554
java代码:
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n;
int prizeNum[] = new int[7];
Arrays.fill(prizeNum, 0);
HashSet<Integer> s = new HashSet<>();
Scanner in = new Scanner(System.in);
n = in.nextInt();
for(int i=0;i<7;++i) {
int temp = in.nextInt();
s.add(temp);
}
for(int i=0;i<n;++i) {
int count = 0;
for(int j=0;j<7;++j) {
int temp = in.nextInt();
if(s.contains(temp))
count++;
}
if(count!=0)
prizeNum[7-count]++;
}
for(int i=0;i<prizeNum.length;++i) {
System.out.print(prizeNum[i]);
if(i != prizeNum.length-1)
System.out.print(" ");
}
}
}