hdu 5326 Work(杭电多校赛第三场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5326
Work
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 583 Accepted Submission(s):
392
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
has a title, everyone except the boss has a direct leader, and all the
relationship forms a tree. If A’s title is higher than B(A is the direct or
indirect leader of B), we call it A manages B.
Now, give you the relation of
a company, can you calculate how many people manage k people.
Each test case begins
with two integers n and k, n indicates the number of stuff of the
company.
Each of the following n-1 lines has two integers A and B, means A is
the direct leader of B.
1 <= n <= 100 , 0 <= k < n
1 <=
A, B <= n
above.
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int n,m,Map[][]; int dfs(int x)
{
int sum=;
for (int i=;i<=n;i++)
{
if (Map[x][i]==)
{
sum++;
sum+=dfs(i);
}
}
return sum;
} int main()
{
int a,b,ans;
while (~scanf("%d%d",&n,&m))
{
ans=;
memset(Map,,sizeof(Map));
//memset(ok,0,sizeof(ok));
for (int i=; i<=n-; i++)
{
scanf("%d%d",&a,&b);
Map[a][b]=;
}
for (int i=;i<=n;i++)
{
if (dfs(i)==m)
ans++;
}
printf ("%d\n",ans);
}
return ;
}
hdu 5326 Work(杭电多校赛第三场)的更多相关文章
- hdu 5319 Painter(杭电多校赛第三场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5319 Painter Time Limit: 2000/1000 MS (Java/Others) ...
- hdu 5373 The shortest problem(杭电多校赛第七场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 The shortest problem Time Limit: 3000/1500 MS (J ...
- hdu 5328 Problem Killer(杭电多校赛第四场)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5328 题目大意:找到连续的最长的等差数列or等比数列. 解题思路:1.等差等比的性质有很多.其中比较重 ...
- HDU 5762 Teacher Bo (鸽笼原理) 2016杭电多校联合第三场
题目:传送门. 题意:平面上有n个点,问是否存在四个点 (A,B,C,D)(A<B,C<D,A≠CorB≠D)使得AB的横纵坐标差的绝对值的和等于CD的横纵坐标差的绝对值的和,n<1 ...
- HDU 5752 Sqrt Bo (思维题) 2016杭电多校联合第三场
题目:传送门. 题意:一个很大的数n,最多开5次根号,问开几次根号可以得到1,如果5次还不能得到1就输出TAT. 题解:打表题,x1=1,x2=(x1+1)*(x1+1)-1,以此类推.x5是不超过l ...
- HDU 5754 Life Winner Bo (各种博弈) 2016杭电多校联合第三场
题目:传送门 题意:一个国际象棋棋盘,有四种棋子,从(n,m)走到(1,1),走到(1,1)的人赢,先手赢输出B,后手赢输出G,平局输出D. 题解:先把从(n,m)走到(1,1)看做是从(1,1)走到 ...
- HDU 4627 The Unsolvable Problem 杭电多校联赛第三场1009 数学题
题意描述:给出一个n,要求在所有满足n = a+b的a和b里面求a和b的最小公倍数最大的两个数的最小公倍数. 解题报告:比赛的时候看到这个题的第一反应就是寻找这两个数一定是在a和b比较接近的地方找,这 ...
- 可持久化线段树的学习(区间第k大和查询历史版本的数据)(杭电多校赛第二场1011)
以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之 ...
- HDU 5821 Ball (贪心排序) -2016杭电多校联合第8场
题目:传送门. 题意:T组数据,每组给定一个n一个m,在给定两个长度为n的数组a和b,再给定m次操作,每次给定l和r,每次可以把[l,r]的数进行任意调换位置,问能否在转换后使得a数组变成b数组. 题 ...
随机推荐
- HostsConfig文件修改器
Hosts文件修改器 HostsConfig v1.1 免费版 最近工作需要,经常需要更换各种域名的内外网配置,频繁的修改HOSTS文件,很多的时间都用在的修改HOSTS文件上,工作效率大大降低,课余 ...
- javascriptDOM编程
DOM - Document Object Model,它是W3C国际组织的一套Web标准,它定义了访问HTML文档对象的一套属性,方法和事件. <html> <head> & ...
- django的第一个问题
/usr/local/lib/python2.7/dist-packages/allauth/account/utils.py in setup_user_email, line 258 /usr/l ...
- IP地址转换32为长整型
Programming Question: Convert an IPv4 address in the format of null-terminated C string into a 32-bi ...
- 【.Net】在WinForm中选择本地文件
相信很多朋友在日常的编程中总会遇到各钟各样的问题,关于在WinForm中选择本地文件就是很多朋友们都认为很难的一个学习.net的难点, 在WebForm中提供了FileUpload控件来供我们选择本地 ...
- 【uoj#310】[UNR #2]黎明前的巧克力 FWT
题目描述 给出 $n$ 个数,从中选出两个互不相交的集合,使得第一个集合与第二个集合内的数的异或和相等.求总方案数. 输入 第一行一个正整数 $n$ ,表示巧克力的个数.第二行 $n$ 个整数 $a_ ...
- bug:margin合并
demo1和demo2存在margin合并问题:外边距合并指的是,当两个垂直外边距相遇时,它们将形成一个外边距.合并后的外边距的高度等于两个发生合并的外边距的高度中的较大者.弥补方案:bfc; 添加一 ...
- C++11线程使用总结
std::thread 在 <thread> 头文件中声明,因此使用 std::thread 需包含 <thread> 头文件. <thread> 头文件摘要 &l ...
- Mybatis笔记二:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
错误异常:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.test.dao.N ...
- 洛谷 P4027 [NOI2007]货币兑换 解题报告
P4027 [NOI2007]货币兑换 题目描述 小 \(Y\) 最近在一家金券交易所工作.该金券交易所只发行交易两种金券:\(A\) 纪念券(以下简称 \(A\) 券)和 \(B\) 纪念券(以下简 ...