摘要:
字符串处理View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;string st;int main(){ //freopen("t.txt", "r", stdin); cin >> st; bool java = false; bool cpp = false; if (st[0] == '_') { cout << 阅读全文
posted @ 2011-09-15 21:13
undefined2024
阅读(343)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;#define maxn 105int n, m;int f[maxn];int g[maxn];bool vis[maxn];void input(){ scanf("%d%d", &n, &m); for (int i = 0; i < n; 阅读全文
posted @ 2011-09-15 20:52
undefined2024
阅读(203)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 1005int n;int f[maxn][maxn];int gcd(int x, int y){ if (!x || !y) return x > y ? x : y; for (int t; t = x % y; x = y, y = t) ; return y;}int main(){ //freop 阅读全文
posted @ 2011-09-15 18:38
undefined2024
阅读(187)
评论(0)
推荐(0)
摘要:
简单模拟,每次看当前的牌是否与初始状态相同,若相同则说明进入循环。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxl 205char s1[maxl], s2[maxl], aim[maxl], st[maxl], s3[maxl];int l;int main(){ //freopen("t.txt", "r", stdin); 阅读全文
posted @ 2011-09-15 18:05
undefined2024
阅读(245)
评论(0)
推荐(0)
摘要:
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
阅读(173)
评论(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)