摘要:
pairs的组合只可能是3+3或者3+4所以其余长度的单词无需记录把记录后的单词n^2枚举pairView Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;char pre1[30] = "qwertyuiopasdfghjklzxcvbnm";int pre2[30] ={ 7, 6, 1, 2, 2, 5, 4, 1, 3, 5, 2, 1, 4, 6, 5, 5, 7, 6, 阅读全文
posted @ 2011-08-29 20:26
undefined2024
阅读(294)
评论(0)
推荐(0)
摘要:
深搜简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 25int n, m;char map[maxn][maxn];bool vis[30];int ans;int dir[4][2] ={{ 0, 1 },{ 1, 0 },{ -1, 0 },{ 0, -1 } };bool ok(int x, int y){ if (x < 0 || y < 0 阅读全文
posted @ 2011-08-29 19:23
undefined2024
阅读(288)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;int value[300];char st[1000000];bool ok(int n){ int len = strlen(st); for (int i = 0; i < len; i++) if (value[st[i]] >= n) return false; int temp = 0; int w = n - 1; 阅读全文
posted @ 2011-08-29 18:58
undefined2024
阅读(273)
评论(0)
推荐(0)
摘要:
求割点模板:void dfs(int fa, int u){ low[u] = dfn[u] = cnt++; for (int i = 0; i < n; i++) if (g[u][i] && i != fa) { if (dfn[i] == -1) { dfs(u, i); low[u] = min(low[i], low[u]); if (dfn[u] <= low[i]) i... 阅读全文
posted @ 2011-08-29 15:27
undefined2024
阅读(152)
评论(0)
推荐(0)
摘要:
递归注意:The input consists of a number of sentences consisting only of characters p through z and N, C, D, E, and I.这句话是错的,句子还会包含不合法字符。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxl 500char st[maxl];int find(cha 阅读全文
posted @ 2011-08-29 14:09
undefined2024
阅读(251)
评论(0)
推荐(0)
摘要:
二分简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 10005int n, k;long long f[maxn];long long sum;bool ok(long long a){ long long cnt = 0; for (int i = 0; i < n; i++) cnt += f[i] / a; return cnt >= k;}l 阅读全文
posted @ 2011-08-29 13:37
undefined2024
阅读(808)
评论(0)
推荐(0)
摘要:
动态规划View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 105struct Gangster{ int s, t, p;}g[maxn];int n, k, t;int f[maxn];bool operator < (const Gangster &a, const Gangster &b){ 阅读全文
posted @ 2011-08-29 09:45
undefined2024
阅读(289)
评论(0)
推荐(0)
摘要:
题意:给定一些硬币,已知其中有一个假硬币重量与其余不同,其余硬币重量相同。给出若干次天平测量结果,问能否判断出这个硬币是哪个,若能则输出是哪个。分析:两端重量相等则两端的硬币都是真的,每个不等情况中必然包含那个假的,且每次出现在同一边(总在小的一边或总在大的一边)。也就是说,只要某些硬币在不等 的一边中不是每次都出现,则它一定是真的。用以上方法进行判断哪些是真的,暂时忽略没出现过的,看有多少个不是真的,如果只有一个则必然是结果,若有多个则无法判断。如果出现过的都是真的,看没出现过的有几个,如果只有一个则为结果,否则无法判断。还有人说可以暴力枚举哪个球是有问题的,是轻是重,每次观察与测量结果是否 阅读全文
posted @ 2011-08-29 09:19
undefined2024
阅读(1129)
评论(0)
推荐(0)