上一页 1 ··· 119 120 121 122 123 124 125 126 127 ··· 182 下一页
摘要: 题意:问母串中至少去掉多少个字母才能是刚好由单词表中的一些单词连接而成的。分析:dp,f[i]表示母串从第i位起始的后缀所对应的最少去掉字母数。f[i]有两种选择f[i + 1] + 1或者f[i + num] + num - strlen(word[j])。其中num是从第i位开始匹配word[j]所需要的母串从i位起始的后缀的前缀的长度。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>usingnamespace std;#de 阅读全文
posted @ 2011-07-02 12:55 undefined2024 阅读(1002) 评论(1) 推荐(1)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int n, m, a[10], la, ans;bool reject;bool split[10], ansplit[10];void work(){ la = 0; while (n > 0) { a[la] = n % 10; n /= 10; la++; } for (int i = 0; i < la / 2; i+ 阅读全文
posted @ 2011-07-02 09:55 undefined2024 阅读(381) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 105struct Node{ int va, vb, step, pre, opr;} q[maxn * maxn];int a, b, c, l, r;bool vis[maxn][maxn];int stk[maxn * maxn], top;void make(int va, int vb, int opr 阅读全文
posted @ 2011-07-02 08:57 undefined2024 阅读(162) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 105struct Node{ int va, vb, step, pre, opr;} q[maxn * maxn];int a, b, c, l, r;bool vis[maxn][maxn];int stk[maxn * maxn], top;void make(int va, int vb, int opr 阅读全文
posted @ 2011-07-02 08:42 undefined2024 阅读(124) 评论(0) 推荐(0)
摘要: 题意:很难理解,是说一个队列,给出原始队列,并每次把原始队列中位置a的元素挪到b位置,先不考虑其余元素位置。进行了所有操作后,其余元素依次填入队列的空位,并保持前后顺序不变。问操作后的队列。题中说明每个元素只会被挪一次,而且每个要挪到的位置也只会出现一次。分析:可以直接模拟。我们可以用两个数组,把第一个数组中的元素挪到第二个数组的指定位置,没有挪的依次填入第二个数组即可。View Code #include #include #include #include usingnamespace std;#define maxn 25#define maxl 20char name[maxn][ma 阅读全文
posted @ 2011-07-01 21:26 undefined2024 阅读(240) 评论(0) 推荐(0)
上一页 1 ··· 119 120 121 122 123 124 125 126 127 ··· 182 下一页