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