多校3 1011 Work
2015-07-28 20:31
423 查看
Work
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 230 Accepted Submission(s): 171
[align=left]Problem Description[/align]
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int n,k,s; int a[105][105]; int dfs(int g) { for(int i=1;i<=n;i++) { if(a[g][i]==1) { s++; dfs(i); } } return 0; } int main() { int i,j,x,y; while(scanf("%d %d",&n,&k)!=EOF) { memset(a,0,sizeof(a)); for(i=1;i<=n-1;i++) { scanf("%d %d",&x,&y); a[x][y]=1; } int ans=0; for(i=1;i<=n;i++) { s=0; dfs(i); if(s==k) ans++; } printf("%d\n",ans); } }
View Code
相关文章推荐
- hdu 5288 OO’s Sequence(two point + rmq)
- 【汇总】UNP第一个程序daytime端口开启。。。。
- PAT (Advanced Level) 1068. Find More Coins (30) DFS+剪枝 或 动态规划
- Java学习之路0728(十二)(Class类、反射、Annotation功能注解)
- HDOJ 1896 Stones(优先队列)
- APP首次启动引导界面和启动界面设置——iOS开发
- 【面试加分项】java异常处理之try_catch_finally
- IOS被遗忘的知识
- OC中 static 与 const 的作用
- Activity里添加ViewGroup ViewGroup里添加ViewGroup
- tinyxml使用笔记与总结 http://www.cppblog.com/elva/archive/2008/04/24/47907.html
- hdu 5319 Painter
- Reorder List
- 判断单链表是否有环以及环的连接点
- 百练2757最长上升子序列
- IndexError: list index out of range的错误原因
- JSP概述
- 渣渣ACM日记——3461-Oulipo(POJ)
- VS中使用TinyXml操作xml文件
- Android ViewPager引导页(三)