
Dynamic Programming
QQQUQ
>_>
展开
-
POJ1458 Common Subsequence
/*problem: 最长公共子序列*/ #include #include #include #include using namespace std; const int maxn = 1005; int dp[maxn][maxn]; int main() { string str1, str2; while (cin >> str1 >> str2) { memset原创 2014-07-19 11:23:32 · 312 阅读 · 0 评论 -
HDU1003 Max Sum
#include #include #include #include #include using namespace std; const int maxn = 100005; int dp[maxn], g[maxn]; struct node { int spos, epos; }; node q[maxn]; int main() { int cas, t = 0,原创 2014-07-19 11:25:48 · 411 阅读 · 0 评论 -
HDU2191
/*problem: 多重背包*/ #include #include #include using namespace std; const int maxn = 105; int dp[maxn], cost[maxn], value[maxn], Count[maxn]; int v, n; void ZeroOnePack(int C, int V) { for (int原创 2014-07-19 10:54:41 · 467 阅读 · 0 评论 -
POJ2063 Investment
/*problem: 多重背包*/ #include #include #include using namespace std; const int maxn = 100005; int dp[maxn], cost[25], value[25]; int main() { int cas, n, v, y, ans; cin >> cas; while (cas--) {原创 2014-07-18 20:18:03 · 318 阅读 · 0 评论 -
POJ1887 Testing the CATCHER
/*problem: 最长不下降子序列*/ #include #include #include using namespace std; int main() { int n, cas = 0; vector v, f; while (cin >> n && n != -1) { v.push_back(n); while (cin >> n && n != -1) {原创 2014-07-19 11:07:39 · 367 阅读 · 0 评论 -
POJ1384 Piggy-Bank
/*problem: 完全背包*/ #include #include #include using namespace std; const int maxn = 10005; int dp[maxn]; int cost[1005], value[1005]; int main() { int cas, e, f, v, n; cin >> cas; while (cas--原创 2014-07-18 20:52:49 · 318 阅读 · 0 评论 -
POJ1163 The Triangle
#include #include using namespace std; const int maxn = 105; int main() { int g[maxn][maxn], N; while (cin >> N) { for (int i = 0; i < N; ++i) { for (int j = 0; j <= i; ++j) cin >> g[i原创 2014-07-19 11:12:47 · 340 阅读 · 0 评论 -
POJ 3624 Charm Bracelet
/*algorithm: 01背包*/ #include #include #include using namespace std; const int maxn = 15000; int w[maxn], v[maxn], dp[maxn]; int main() { int n, m, ans; while (cin >> n >> m) { memset(dp, 0,原创 2014-07-18 14:28:40 · 370 阅读 · 0 评论