摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3732思路:这么大的数据,用01背包肯定会TLE的,01背包转多重背包。。最多也就11*11=121件物品。。。View Code 1 #include<iostream> 2 using namespace std; 3 int dp[10010]; 4 int map[14][14]; 5 int n,m; 6 7 void CompletePack(int value,int cost){ 8 for(int j=cost;j<=m;j++){ 9 dp[j]=ma... 阅读全文
posted @ 2013-04-06 21:11 ihge2k 阅读(302) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999思路:创建一颗二叉排序树,直接先序遍历即可。View Code 1 #include 2 using namespace std; 3 bool first; 4 5 struct BST{ 6 int data; 7 BST *leftchild; 8 BST *rightchild; 9 };10 11 void Build(BST *&root,int x){12 if(root==NULL){13 root=(BST *)malloc... 阅读全文
posted @ 2013-04-06 11:38 ihge2k 阅读(340) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1426思路:dfs搜索(回溯),有个小技巧,就是行、列的表示,具体见代码。。View Code 1 #include<iostream> 2 using namespace std; 3 bool flag; 4 int map[10][10]; 5 int row[10][10]; 6 int line[10][10]; 7 struct Matrix{ 8 bool num[10]; 9 }mat[4][4];//小的九宫格10 11 12 void dfs(int _count){ 阅读全文
posted @ 2013-04-06 09:47 ihge2k 阅读(293) 评论(0) 推荐(0) 编辑