摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4474思路:bfs,用pre[]来记录到达u的前一个结点,num[]来保存当前数的最后一位。具体见代码:View Code 1 #include 2 #include 3 #include 4 const int N=10010; 5 using namespace std; 6 int n,m; 7 int a[10]; 8 int pre[N],num[N]; 9 10 void print(int u){11 if(pre[u]!=-1)print(pre[u]);//pre[]保存... 阅读全文
posted @ 2013-03-24 15:36 ihge2k 阅读(462) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4472思路:每次都要把那个终极boss除去,然后dp[i]=sum{dp[j]}((i-1)%j==0);原因:根据题意,一个节点一定要用去做树根,所以剩下i-1个点,这i-1个节点把它分成几份,这几份完全相同,其本身强烈对称,然后不断更新就行了。。。orzView Code 1 #include<iostream> 2 const int N=1010; 3 const int MOD=1e9+7; 4 using namespace std; 5 int dp[N]; 6 7 voi 阅读全文
posted @ 2013-03-24 11:15 ihge2k 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4517昨天Tencent的题目,好吧,当时悲剧地TLE了。。。。orz,今天网上搜了一下,基本上都是用dp做的。。。orz。。。思路:sum[i][j]表示从1-i,1-j的矩阵中的'*'的个数。。。View Code 1 #include<iostream> 2 const int N=2004; 3 using namespace std; 4 char map[N][N]; 5 int sum[N][N];//sum[i][j]表示从1-i,1-j的矩形中的&quo 阅读全文
posted @ 2013-03-24 09:41 ihge2k 阅读(278) 评论(0) 推荐(0) 编辑