Who are your potential friends?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.