-
Title Description:
-
"SquarePants Underwater"-This is the word we like to use when we describe our friends. Two people are friends usually means that they have a lot of common interests. As an otaku, however, you find that you don't have a lot of opportunities to get to know each other. Fortunately, you accidentally got a book borrowing records from the Peking University Library, so you midnight oil to stay up late and program to find potential friends from it. First of all, you have a record of the borrowing records, the N readers sequentially numbered,..., N, the M book is numbered,..., m. At the same time, according to the "SquarePants underwater" principle, and the person you like to read the same book, is your potential friend. Your task now is to calculate from this borrowing record how many potential friends each person has.
-
Input:
-
The first line of each case is two integers n,m,2 <= N, m<= 200. Next there are N rows, and the first (i =,..., N) row has a number that represents the reader I-1 's favorite book's number P (1<=p<=m)
-
Output:
Each case consists of n rows, one number per line, and the number of rows I indicates that reader I has several potential friends. If I and anyone do not have a common favorite book, then output "beiju" (i.e. tragedy, ^ ^)
-
Sample input:
-
4 5
-
2
-
3
-
2
-
1
-
Sample output:
-
1
-
Beiju
-
1
-
Beiju
#include <stdio.h>intMain () {intn,m; while(SCANF ("%d", &n)! =EOF) { intm[201] = {0}; intn[ +]={0}; scanf ("%d",&m); for(intI=0; i<n; i++) {scanf ("%d",&N[i]); M[n[i]]++; } for(intI=0; i<n; i++){ if(M[n[i]] = =1) printf ("beiju\n"); Elseprintf ("%d\n", m[n[i]]-1); } } return 0;}
Who are your potential friends?