ACM: 动态规划题 poj 2486
来源:互联网 发布:金山tw域名遭抢注 编辑:程序博客网 时间:2024/06/07 23:00
Input
Each test case contains three parts.
The first part is two numbers N K, whose meanings we have talkedabout just now. We denote the nodes by 1 2 ... N. Since it is atree, each node can reach any other in only one route.(1<=N<=100,0<=K<=200)
The second part contains N integers (All integers are nonnegativeand not bigger than 1000). The ith number is the amount of applesin Node i.
The third part contains N-1 line. There are two numbers A,B in eachline, meaning that Node A and Node B are adjacent.
Input will be ended by the end of file.
Note: Wshxzt starts at Node 1.
Output
Sample Input
2 1
0 11
1 2
3 2
0 1 2
1 2
1 3
Sample Output
11
2
题意: 女孩Wshxzt喜欢吃苹果, HX带她到一棵苹果树中, 苹果树每个节点有一定数量的苹果,
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 105
int n, K;
int g[MAX][MAX], num[MAX], a[MAX];
int dp[MAX][MAX*2][2];
bool vis[MAX];
inline int max(int a, int b)
{
}
void dfs(int u)
{
}
int main()
{
//
}
- ACM: 动态规划题 poj 2486
- ACM: 简单动态规划题 poj 2955
- ACM: 动态规划题 poj 2241
- ACM: 动态规划题 poj 1054
- ACM: 动态规划题 poj 2948
- ACM: 动态规划题 poj 1925
- ACM: 动态规划题 poj 3034
- ACM: 动态规划题 poj 2411
- ACM: 动态规划题 poj 1947
- ACM: 动态规划题 poj 3140
- ACM: 动态规划题 poj 3659
- ACM: 动态规划题 poj 2923
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: 树状DP 动态规划题 poj 1463 …
- ACM: 动态规划题 poj 2057 树状DP
- ACM:动态规划题 poj 1015
- ACM: 动态规划题 poj&nb…
- 兴趣学习: 摆脱“三天打渔两天晒网”…
- ACM: 动态规划题 poj 1185 想了两…
- windows.h
- ACM: 动态规划题 poj 2057 树状DP
- ACM: 动态规划题 poj 1947
- ACM: 动态规划题 poj 2486
- ACM: 动态规划题 poj 3140
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 1192 树形DP
- ACM: 动态规划题 poj 3659
- 动态规划: 经典0-1背包问题 (转)
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 3211 背包变…
- (OK)(OK) Fedora23——NS3(MANETs)——Docker(busybox)——genymotion(android)——All is OK