随笔分类 - ACM_字符串
摘要:题目链接:http://poj.org/problem?id=1686思路分析:该问题为表达式求值问题,对于字母使用浮点数替换即可,因为输入中的数字只能是单个digit。代码如下:#include #include #include #include #include #include using ...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5311思路分析:该问题要求在字符串中是否存在三个不相交的子串s[l1..r1], s[l2..r2], s[l3..r3]能够拼接成模式串,而且满足要求1≤l1≤r1#include #include u...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1544问题分析:问题要求求出字符串的连续子串中的回文子串个数。首先,需要区分连续子串与子序列的区别。连续子串为连续的字符组成的字符串;子序列需要满足在子序列中出现的字符的相对顺序与字符串中出现的相对顺序相...
阅读全文
摘要:题目链接:http://poj.org/problem?id=2406思路分析:1.理解Kmp算法的next数组的意义;2.对于字符A[i],i-next[i]等价于在字符串中存在一个长度为i-next[i]的重复子串;3.当 i % (i - next[i]) == 0 等价于字符串由 (i/(i...
阅读全文
摘要:题目链接:http://poj.org/problem?id=1056思路分析:检测某字符串是否为另一字符串的前缀,数据很弱,可以使用暴力解法。这里为了练习KMP算法使用了KMP算法。代码如下:#include using namespace std;const int N = 10;const i...
阅读全文
摘要:题目链接:http://poj.org/problem?id=1298思路分析:水题,字符偏移求解,注意字符串输入问题即可。代码如下:#include #include using namespace std;const int MAX_N = 200 + 10;char A[MAX_N];int ...
阅读全文
摘要:题目链接:http://poj.org/problem?id=3461思路分析:字符串匹配问题,使用KMP算法解决。代码如下:#include char T[1000005], W[10005];int Next[10005];int Len_T, Len_W;void GetNext( ){ ...
阅读全文

浙公网安备 33010602011771号