Codeforces Round #253 (Div. 2), problem: (B)【字符串匹配】
2014-06-24 23:23
405 查看
简易字符串匹配,题意不难
#include <stdio.h> #include <string.h> #include <math.h> #include <iostream> #include <algorithm> using namespace std; int main(){ int i, j, k, t, n; int num, flag, ans; char a[300]; scanf("%s",a); scanf("%d",&k); int len = strlen(a); num = len + k; num /= 2; flag = 0; for(n = num; n > 0; --n){ for(j = 0; j < len; ++j){ i = j; while(i < j + n && i <(len + k - n)){ if((i + n) >= len){ ++i; continue; } if(a[i] == a[i + n]){ ++i; continue; } else break; } if(i == j + n){ flag = 1; break; } } if(flag) break; } printf("%d\n",n * 2); return 0; }
相关文章推荐
- Codeforces Round #253 (Div. 1) B. Andrey and Problem
- Codeforces Round #253 (Div. 2) D. Andrey and Problem
- CodeforcesRound#253(Div2) D Andrey and Problem
- Codeforces Round #207 (Div. 2) Xenia and Hamming(字符串匹配)
- Codeforces Round #253 (Div. 1) B. Andrey and Problem
- Codeforces Round #253 Div2 D.Andrey and Problem 概率+贪心
- Codeforces Round #253 (Div. 2) D. Andrey and Problem (贪心+数学概率)
- Codeforces Round 40 (Rated for Div. 2) B 字符串 不互用字符字串问题
- 【Codeforces Round 169 (Div 2) E】【数据结构区间维护】Little Girl and Problem on Trees 大菊花树的距离性修改查询
- Codeforces Round #253 (Div. 2)——Borya and Hanabi
- Codeforces Round #253 DIV1 C 馋
- Codeforces Round #328 (Div. 2)Problem A. PawnChess(模拟)
- Codeforces Round #253 (Div. 1) (A, B, C)
- Codeforces Round #253 (Div. 1) A Borya and Hanabi
- Codeforces Round 40 (Rated for Div. 2) B 字符串 不互用字符字串问题
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) B - Save the problem!
- Educational Codeforces Round 46 (Rated for Div. 2) D. Yet Another Problem On a Subsequence
- Codeforces Round #253 (Div. 1)D题
- Codeforces Round #228 (Div. 2), problem: (A) Fox and Number Game
- Codeforces Round #253 (Div. 2) B - Kolya and Tandem Repeat