![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划专题
文章平均质量分 76
hui1570
这个作者很懒,什么都没留下…
展开
-
动态规划—北大POJ Charm Bracelet(01背包问题)
Charm BraceletTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 23067 Accepted: 10377DescriptionBessie has gone to the mall's jewelry store and spies a原创 2014-08-01 19:44:50 · 452 阅读 · 0 评论 -
递归—简单背包问题
简单的背包问题【问题描述】设有一个背包,可以放入的重量为s。现有n件物品,重量分别为w1,w2…,wn,(1≤i≤n)均为正整数,从n件物品中挑选若干件,使得放入背包的重量之和正好为s。找到一组解即可。【输入格式】第一行是物品总件数和背包的载重量,第二行为各物品的重量。【输出格式】各所选物品重量。【输入样例】10 51 2 3 4 5【输出样例】nu原创 2014-08-01 12:01:00 · 990 阅读 · 0 评论 -
动态规划—杭电ACM 1203 I NEED A OFFER!(01背包问题)
#include#include#includeint a[10010];float b[10010],f[110000];int main(){ int i,j,n,m; while(scanf("%d%d",&n,&m)&&(m!=0||n!=0)) { for(i=0;i f[i]=1; for(i=1;i { sca原创 2014-08-01 21:34:43 · 651 阅读 · 0 评论 -
动态规划—杭电ACM Bone Collector(01背包问题)
Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave原创 2014-08-02 10:13:04 · 491 阅读 · 0 评论 -
北大POJ1159 Palindrome(动态规划求最长公共子序列)
#include#include#includechar str1[5010],str2[5010];short f[5010][5010];int max(int a,int b){ if(a>=b) return a; else return b;}void exchange(int n) //将输入的字符串数组倒置原创 2014-08-04 11:55:53 · 351 阅读 · 0 评论 -
经典背包问题 01背包+完全背包+多重背包
01背包有n种不同的物品,每个物品有两个属性,size体积,value 价值,现在给一个容量为 w 的背包,问最多可带走多少价值的物品。 [cpp]view plaincopyprint?int f[w+1]; //f[x] 表示背包容量为x 时的最大价值 for (int i=0; i for (int j=w; j>=size[i转载 2014-08-02 09:28:05 · 424 阅读 · 0 评论 -
杭电ACM 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活(多重背包问题)
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活Problem Description急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?后记:人生是一个充满了变数的生命过程,天灾、人祸原创 2014-08-04 18:03:17 · 357 阅读 · 0 评论