摘要:
bfsView Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxw 85#define maxh 1005struct Point{ int x, y; Point(int xx, int yy) : x(xx), y(yy) { } Point() { }} q[maxw * maxh];int w, h;char map[maxh][maxw];bool vis[max... 阅读全文
posted @ 2011-09-15 16:25
undefined2024
阅读(166)
评论(0)
推荐(0)
摘要:
题意:把n个一样的蛋糕放进m个一样的盘子,有多少种方法。分析:dp,f[i][j]表示i个盘子装j个蛋糕的方法数。分两种情况,有空盘方法数为f[i - 1][j](撤掉一个空盘),无空盘的方法数为f[i][j - i](每个盘子撤掉一个蛋糕)。采用滚动数组。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 4505#define w 1000000007int n, m 阅读全文
posted @ 2011-09-15 13:42
undefined2024
阅读(172)
评论(0)
推荐(0)
摘要:
题意:给n,k,求c(n,k)的约束个数。分析:用组合数学的方法求因子个数,我们分别对n!,(n-k)!,k!分解质因数。c(n,k)=n!/((n-k)!k!),把对应因子个数相减,我们就得到了c(n,k)分解的结果。把取每个质因子的方法数相乘即为所求。所以我们需要一种快速分解x!的方法。我们可以枚举所有x!中存在的素因子,对于每个素因子求个数的方式来分解。而对于一个素因子p,我们求在x!中的方法如下,1~x中有x/p个数可以被p整除,所以x!中至少有x/p个p。然后我们再看有多少个p^2。能被p^2整除的数一定能被p整除。所以我们先将1~x中不能被p整除的数刨除。再将剩下的数除以p。现在还 阅读全文
posted @ 2011-09-15 10:37
undefined2024
阅读(763)
评论(0)
推荐(0)