2012年10月30日

ACM第五乐章--数论

摘要: /*Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).*/#include<stdio.h>#include<string.h>long long mod = 9901;long long exp(long long a,long long b,long long c){ long long ans = 1; while( 阅读全文

posted @ 2012-10-30 09:18 aigoruan 阅读(181) 评论(0) 推荐(0)

ACM的第三乐章---状态DP

摘要: poj 1185http://poj.org/problem?id=1185/*Problem: 1185 User: ruan123Memory: 2128K Time: 266MSLanguage: G++ Result: Accepted说下dp方程:dp[i][j][k] 为第i行状态为Sj,第i-1行状态为Sk时前i行最多能放置的炮数。 */#include <stdio.h>#include <string.h>#include <stdlib.h>int dp[105][65][65];int s[105],map[105],cnt,c[... 阅读全文

posted @ 2012-10-30 09:16 aigoruan 阅读(197) 评论(0) 推荐(0)

ACM的第二乐章--BFS

摘要: bfs和dfs一样,也是以树形搜索形状进行的,只不过dfs是以树根开始一个个的搜索,而bfs则以步数、层次展开搜索,也就是从树根一层层的向外拓展。这种拓展需要的空间一般都是指数级的,所以不能像dfs一样灵活搜索,往往都是在一定的剪枝策略下展开的,因而bfs一般适合求解最优解。标志性的bfs里会有一个... 阅读全文

posted @ 2012-10-30 09:11 aigoruan 阅读(166) 评论(0) 推荐(0)

导航