uva 12186 DP
来源:互联网 发布:注册音乐人软件 编辑:程序博客网 时间:2024/05/17 11:33
#include<cstdio>#include<cstring>#include<algorithm>#include<vector>using namespace std;int n,t,x;vector<int> g[100010];int dfs(int u){if(g[u].empty()) return 1;int k=g[u].size();vector<int>d;for(int i=0;i<k;i++) d.push_back(dfs(g[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)==2 && (n || t)){for(int i=0;i<=n;i++) g[i].clear();for(int i=1;i<=n;i++){scanf("%d",&x);g[x].push_back(i);}printf("%d\n",dfs(0));}}
阅读全文
0 0
- uva 12186 DP
- UVa 12186 Another Crisis dp:树上dp
- UVA 12186 树上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)
- 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 )
- java常见的四个运行时期的异常
- Java Web 中使用Hibernate开发的步骤
- linux学习(2)
- malloc与free的底层实现
- CTF 实验吧 Forms
- uva 12186 DP
- 【队内胡策】2017.10.10
- 随机森林(Random Forest)(一)
- Yii2自动加载
- 生活娱乐 为什么台秤秤不准
- 生活娱乐 在上海怎么租房
- HDU
- 生活娱乐 在船上工作着的心声
- Spring Cloud学习笔记