UVA 12186 - Another Crisis(树形DP)
来源:互联网 发布:mac怎么关掉程序快捷键 编辑:程序博客网 时间:2024/04/27 23:37
这个题 真难读懂。
题目还是很简单的。队友每一个领导 都要找出他的员工的最小的人数。 这是一个最基本的子问题 然后递归就OK。
#include <cstdio>#include <algorithm>#include <iostream>#include <cstring>#include <cmath>#include <cstdlib>#include <string>#include <map>#include <vector>#include <set>#include <queue>#include <stack>using namespace std;#define ll long long#define maxn 100000+10#define INF 1<<30vector <int> sons[maxn];int n,t;int dp(int u){ if(sons[u].empty()) return 1; int k = sons[u].size(); vector <int> d; for(int i = 0; i < k ; i++){ d.push_back(dp(sons[u][i])); } sort(d.begin(),d.end()); int c = (k*t - 1) / 100 + 1; int ans = 0; for(int i = 0; i < c; i++) ans += d[i]; return ans;}int main (){ while(scanf("%d%d",&n,&t) != EOF){ if(n == 0 && t ==0) break; for(int i = 1; i <= n; i++){ int num; scanf("%d",&num); sons[num].push_back(i); } int co = dp(0); printf("%d\n",co); for(int i = 0; i <= maxn; i++) sons[i].clear(); } return 0;}
0 0
- UVA 12186 - Another Crisis(树形DP)
- UVA 12186 Another Crisis(树形DP)
- UVa 12186 Another Crisis(树形DP)
- UVa 12186 - Another Crisis(树形DP)
- UVa 12186 - Another Crisis(树形DP)
- UVA - 12186 Another Crisis (树形dp)
- UVA - 12186 Another Crisis (树形DP)
- Another Crisis - UVa 12186 树形dp
- UVA 12186 Another Crisis 树形DP
- uva 12186 Another Crisis 树形dp
- UVA - 12186 Another Crisis 水树形dp
- UVA 12186 Another Crisis [树形dp]
- uva 12186 Another Crisis 树形DP
- UVa - 12186 - Another Crisis ( 树形DP )
- 【树形DP】UVa 12186 Another Crisis
- UVA 12186 Another Crisis(树形DP)
- UVAOJ 12186Another Crisis(树形DP)
- UVa 12186:Another Crisis(DP)
- 计算CRC16
- TCP与UDP在socket编程中的区别
- [Linux]Makefile入门
- Transfer Learning 资料
- 2014 Multi-University Training Contest 5 HDOJ 4920 Matrix multiplication
- UVA 12186 - Another Crisis(树形DP)
- 关于NSDate于NString的转换
- Cocos2d-x3.1中C++11强枚举类型
- JAVA和C++的区别
- 总结
- 2的32次方
- hive正则表达式
- 电子网站大全
- 外键