Multi-School 3 1011 work

Source: Internet
Author: User

Work

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): Accepted submission (s): 171


Problem Description

It's an interesting experience-to-move from ICPC to work, end my college life and start a brand new journey in company.
As is known to all, every stuff in a company have a title, everyone except the boss have a direct leader, and all the Relati Onship forms a tree. If a ' s title is higher than B (A was the direct or indirect leader of B), we call it A manages B.
Now, give you the relation for a company, can-calculate how many people manage k people.

Inputthere is multiple test cases.
Each test case is begins with a integers n and k, n indicates the number of stuff of the company.
Each of the following n-1 lines have both integers a and B, means a is the direct leader of B.

1 <= N <=, 0 <= k < n
1 <= A, B <= N

Outputfor each test case, output the answer as described above.

Sample Input7 21 21 32 42 53 63 7

Sample Output2

Source2015 multi-university Training Contest 3

Recommendwange2014 | We have carefully selected several similar problems for you:5326 5325 5324 5323 5322
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 6 intn,k,s;7 inta[ the][ the];8 9 intDfsintg)Ten { One      for(intI=1; i<=n;i++) A     { -         if(a[g][i]==1) -         { thes++; - DFS (i); -         } -     } +     return 0; - } +  A intMain () at { -     inti,j,x,y; -      while(SCANF ("%d%d", &n,&k)! =EOF) -     { -Memset (A,0,sizeof(a)); -          for(i=1; i<=n-1; i++) in         { -scanf"%d%d",&x,&y); toa[x][y]=1; +         } -         intans=0; the          for(i=1; i<=n;i++) *         { $s=0;Panax Notoginseng DFS (i); -             if(s==k) theans++; +         } Aprintf"%d\n", ans); the     } +}
View Code

Multi-School 3 1011 work

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.