上一页 1 ··· 73 74 75 76 77 78 79 80 81 ··· 182 下一页
摘要: 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)
摘要: 简单解析几何View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>using namespace std;#define pi acos(-1)double d, D, r, s;int main(){ //freopen("t.txt", "r", stdin); int t; scanf("%d", &t); while ( 阅读全文
posted @ 2011-09-14 13:48 undefined2024 阅读(118) 评论(0) 推荐(0)
摘要: 题意:给一个n*n矩阵,问选n个格,每行一个每列一个,是否任意选法的加和都相等。分析:我们认为我们只选择对角线上的n个格。这样任意两种选法可以通过行列交换来得到。如果要选(1,2)(2,1)可以交换1,2两列,然后仍然选择对角线。由于有些情况可能需要多次交换,这样就要求任意一次交换不能影响加和。所以矩阵中任意的矩形的四角都满足a+c=b+d。即a-b=c-d。即任意两列,所有对应位差相等。有一个简便的判别方法,任意两列对应位差相等<=>所有相邻列对应位差相等。View Code #include <iostream>#include <cstdlib>#in 阅读全文
posted @ 2011-09-14 10:54 undefined2024 阅读(236) 评论(0) 推荐(1)
上一页 1 ··· 73 74 75 76 77 78 79 80 81 ··· 182 下一页