摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722思路:简单的记忆化搜索,留意一下A==0时的情况就可以了。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 typedef long long ll; 7 8 int digit[22]; 9 ll dp[22][12];10 11 ll dfs(int pos,int pre,int doing)12 {13 if(pos==-1){14 return pre==0;15 ... 阅读全文
posted @ 2013-09-11 21:59 ihge2k 阅读(556) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4240思路:题意真的有点难理解:在城市A->B之间通过所有路径一小时之内能通过最大的车辆(Maxflow)/所有边上通过最大车流量(cap)的那条叫做redundancy ratio。最小的redundancy ratio是前者最大的车流量的那一条(cap),问minimum redundancy ratio是多少。其实就是跑一次最大流,每当找到一条增广路时,记录此时的cap,然后取最大的就行了。 1 #include 2 #include 3 #include 4 #include 5 .. 阅读全文
posted @ 2013-09-11 17:50 ihge2k 阅读(559) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1513思路:n这么大,可以采用滚动数组,然后就是求原串和反串的LCS了。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int dp[2][5555]; 8 char str1[5555],str2[5555]; 9 int n;10 11 int main()12 {13 while(~scanf("%d",&n)){14 scanf("%s",str1) 阅读全文
posted @ 2013-09-11 10:32 ihge2k 阅读(223) 评论(0) 推荐(0) 编辑