
杭电25道动态规划
oBiyingo
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
杭电 25道动态规划汇总
HDU 25道动态规划题的解题报告 http://acm.hdu.edu.cn/webcontest/contest_show.php?cid=1264 密码:zafu A. 最简单的dp,但很重要。说明了动态规划产生的动机之一:递归产生的大量重复子问题。有两种解决方法,一、记忆化搜索,就是在用递归处理问题的过程中把已经算过的状态记录在一张表dp[][]中,下一次需要重复原创 2013-05-31 19:28:47 · 1630 阅读 · 0 评论 -
K题 多重背包
#include #include #include using namespace std; #define MAX 300000 int dp[MAX],v[1000],m[1000]; int main() { int i,j,n,k; while(cin>>n&&n>=0) { int sum=0;原创 2013-06-01 20:50:48 · 510 阅读 · 0 评论 -
O题 分组背包变形
#include #include #include using namespace std; const int maxn=10010; int dp[11][10010]; int belong[10010]; int w[10010],v[10010]; int max(int x,int y) { return x>y?x:y; } int main()原创 2013-06-01 20:53:17 · 464 阅读 · 0 评论 -
N题 第K大背包
#include using namespace std; #include #include int dp[205][205],c[200],w[200]; int n,m,k,s; int main() { int i,j; while(cin>>n>>m>>k>>s) { memset(dp,0,sizeof(dp));原创 2013-06-01 20:52:32 · 387 阅读 · 0 评论 -
M题 二维费用背包
#include using namespace std; #include #include int dp[205][205],c[200],w[200]; int n,m,k,s; int main() { int i,j; while(cin>>n>>m>>k>>s) { memset(dp,0,sizeof(dp));原创 2013-06-01 20:51:46 · 397 阅读 · 0 评论 -
F题 求最大矩阵的和
**************推荐大牛的博文************** http://www.matrix67.com/blog/archives/276 #include #include #include using namespace std; int main() { const int size = 101; int Max,sum; int N,i,j原创 2013-06-01 20:47:31 · 367 阅读 · 0 评论 -
H题 完全背包
#include using namespace std; #include #include #define INF 1000000000 int MIN(int a,int b) { if(a>b)return b; else return a; } int E,F,N,M; int main() { int min[20000],P[10原创 2013-06-01 20:49:20 · 413 阅读 · 0 评论 -
D题 最长上升子序列的和
#include using namespace std; #include #define GetMax(a,b) a>b?a:b #define Big __int64 Big dp[1005]={0}; int main() { Big Max; int i,j,n,val[1005]={0}; while (scanf("%d",&n),n) {原创 2013-06-01 20:44:15 · 432 阅读 · 0 评论 -
B题 最长公共子序列
#include using namespace std; #include #include #include #define N 1010 int dp[N][N]; int main () { char s1[N],s2[N]; while(gets(s1),gets(s2)) { int len1 = strlen(s原创 2013-05-31 19:30:28 · 374 阅读 · 0 评论 -
A题 数塔
#include using namespace std; #include #include int main() { int a[101][101]; int i,j,n,t,m; cin>>m; while(m--) { cin>>n; t=0; memset(a,0,sizeo原创 2013-05-31 19:29:47 · 388 阅读 · 0 评论 -
E题 最大连续字段的和
#include using namespace std; #include #include int digit[1005]; int tmp[1005]; int biggest(int n) { int res; int i,k; res=0; tmp[0]=digit[0]; for(i=1;i<n;i++) { //每一次循环之后tmp数原创 2013-06-01 20:45:39 · 623 阅读 · 0 评论