上一页 1 ··· 43 44 45 46 47 48 49 50 51 ··· 61 下一页
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1224我感觉就是求最长上升上升序列View Code 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 const int MAXN=110; 5 int n,m; 6 int dp[MAXN]; 7 int value[MAXN]; 8 int path[MAXN]; 9 bool map[MAXN][MAXN];10 11 void Print(int u){12 if(u==-1)retu 阅读全文
posted @ 2013-04-08 08:15 ihge2k 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3709数位dp...完全看大牛模版理解的。。。。View Code 1 #include<iostream> 2 using namespace std; 3 __int64 dp[19][19][2000]; 4 int digit[19]; 5 6 //pos表示当前的位置,o表示支点,pre表示从最高位到pos的力矩之和,doing表示是否有上限,若无,则为9; 7 __int64 dfs(int pos,int o,int pre,bool doing){ 8 if(pos==- 阅读全文
posted @ 2013-04-07 20:50 ihge2k 阅读(692) 评论(0) 推荐(1) 编辑
摘要: 题目链接: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) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1247思路:用字典树插入所有单词后直接枚举每个单词的每个分割点每个分割点的位置都入栈),然后再依此出栈判断此分割点分成的两个字符串是否都存在即可,如果所有的情况都不存在,返回false,否则,返回true... 阅读全文
posted @ 2013-04-05 17:48 ihge2k 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075wa了好多次啊。。。心都碎了。。。然后不知道怎么一改就对了。。。orz...建树的的时候每个单词的的最后一个结点应该加入译文的信息。。。islower()用于判断小写字母很好用。。。View Cod... 阅读全文
posted @ 2013-04-05 16:36 ihge2k 阅读(416) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1420题目很简单,暴力1A,可应该有更好的方法。。。搜了一下,可以用快速幂。。。我怎么没想到呢。。。如果数据强一点。。估计我又要跪了。。。orz..View Code 1 #include<iostream> 2 #include<cmath> 3 using namespace std; 4 5 __int64 Pow(__int64 a,__int64 b,__int64 c){ 6 __int64 p=1,q=a; 7 while(b){ 8 if(b&1).. 阅读全文
posted @ 2013-04-05 10:45 ihge2k 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1528题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1962思路:求二分图的最小覆盖,最小覆盖=最大匹配;建图略麻烦。。。View Code 1 #include<iostream> 2 const int MAXN=30; 3 using namespace std; 4 int n; 5 bool map[MAXN][MAXN]; 6 int lx[MAXN],ly[MAXN]; 7 bool mark[MAXN]; 8 9 int d 阅读全文
posted @ 2013-04-04 21:54 ihge2k 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068思路:最大独立集 == |P| 减 【最大匹配(双向建图)】/2还是用的vector建邻接表。。。速度比较快。。。View Code 1 #include<iostream> 2 #include<vector> 3 const int N=507; 4 using namespace std; 5 int lx[N],ly[N]; 6 bool mark[N]; 7 vector<int>map[N]; 8 int n; 9 10 int dfs(int 阅读全文
posted @ 2013-04-04 17:44 ihge2k 阅读(197) 评论(0) 推荐(0) 编辑
上一页 1 ··· 43 44 45 46 47 48 49 50 51 ··· 61 下一页