摘要: 题目连接http://poj.org/problem?id=3624View Code 1 #include <stdio.h> 2 #include <string.h> 3 int main() 4 { 5 int n,i,j,w[3500],val[3500],v,f[20000]; 6 while(~scanf("%d %d",&n,&v)) 7 { 8 9 for(i = 1;i <= n;i++)10 {11 scanf("%d %d",&w[i],&val[i]);12 }13 阅读全文
posted @ 2012-08-13 21:57 某某。 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 1. 背包问题介绍背包问题不单单是一个简单的算法问题,它本质上代表了一大类问题,这类问题实际上是01线性规划问题,其约束条件和目标函数如下:自从dd_engi在2007年推出《背包问题九讲》之后,背包问题的主要精髓基本已道尽。本文没有尝试对背包问题的本质进行扩展或深入挖掘,而只是从有限的理解(这里指对《背包问题九讲》的理解)出发,帮助读者更快地学习《背包问题九讲》中的提到的各种背包问题的主要算法思想,并通过实例解释了相应的算法,同时给出了几个背包问题的经典应用。2. 背包问题及应用dd_engi在《背包问题九讲》中主要提到四种背包问题,分别为:01背包问题,完全背包问题,多重背包问题,二维费用 阅读全文
posted @ 2012-08-13 21:16 某某。 阅读(460) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1500大意:输入几个字符串,然后再输入几个字符串,看第一次输入的字符串有多少没有在后面的字符串中出现(后输入的字符串不一定出现在之前的字符串中)代码:View Code 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 struct node 5 { 6 int flag; 7 struct node *next[2 阅读全文
posted @ 2012-08-13 20:44 某某。 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1075大意:有外星人来了,但是我不懂外星文。然后我有一本字典,然我去翻译,字典由start开始有end结束的相当于map转换,然后是由由start开始有end结束的需要翻译的句子。代码#include <stdio.h>#include <string.h>#include <stdlib.h>#include <ctype.h>typedef struct node{ int flag; char ans[55]; struct node *next 阅读全文
posted @ 2012-08-13 20:41 某某。 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 这道题我用得静态树,发现静态树不如动态树啊,虽然时间快点,但是空间要求的也太离谱了~题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1247大意:让你输入几个单词,然后看看这有几个是可以有其他的任意两个单词或者一个单词两次,连接组成的,把他们输出就可以了代码View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 const int N=26; 5 const int maxn=1000000; 6 char s[5000 阅读全文
posted @ 2012-08-13 20:35 某某。 阅读(232) 评论(0) 推荐(0) 编辑