摘要: 题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=21261思路:此题需要记忆化搜索,dp[x][y][t]表示当前状态下是否是否有可能点(x,y)上有贼,0表示不可能,1表示可能,然后及时记忆化搜索。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 111 8 typedef pairPP; 9 10 int n,m,Time,cnt;11 int dp[MAXN][MAXN] 阅读全文
posted @ 2013-09-16 22:05 ihge2k 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3904思路:费用流的题,增加一个超级源点和一个超级汇点,然后就是连边了,对于每个城市,与汇点连边,容量为inf,花费(这里指收益)为商品在该城市的价值,然后对于图中给定的边,容量为cap,花费为-cost(负数代表花费),最后就是源点与城市1连边了,然后就是跑费用流了,求最大收益(当dist[vt] 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 22 阅读全文
posted @ 2013-09-16 20:02 ihge2k 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734思路:记忆化搜索。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int Pow[11]; 7 int dp[11][5050]; 8 int digit[11]; 9 int a,b;10 11 int Get_f(int n)12 {13 int pos=0,res=0;14 while(n){15 digit[pos++]=n%10;16 n/=10... 阅读全文
posted @ 2013-09-16 14:49 ihge2k 阅读(575) 评论(0) 推荐(0) 编辑