302301: CF443B. Kolya and Tandem Repeat

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Kolya and Tandem Repeat

题目描述

Kolya got string $ s $ for his birthday, the string consists of small English letters. He immediately added $ k $ more characters to the right of the string. Then Borya came and said that the new string contained a tandem repeat of length $ l $ as a substring. How large could $ l $ be? See notes for definition of a tandem repeat.

输入输出格式

输入格式


The first line contains $ s $ ( $ 1<=|s|<=200 $ ). This string contains only small English letters. The second line contains number $ k $ ( $ 1<=k<=200 $ ) — the number of the added characters.

输出格式


Print a single number — the maximum length of the tandem repeat that could have occurred in the new string.

输入输出样例

输入样例 #1

aaba
2

输出样例 #1

6

输入样例 #2

aaabbbb
2

输出样例 #2

6

输入样例 #3

abracadabra
10

输出样例 #3

20

说明

A tandem repeat of length $ 2n $ is string $ s $ , where for any position $ i $ ( $ 1<=i<=n $ ) the following condition fulfills: $ s_{i}=s_{i+n} $ . In the first sample Kolya could obtain a string aabaab, in the second — aaabbbbbb, in the third — abracadabrabracadabra.

Input

题意翻译

### 题目大意 有一个字符串 $s$ ,在字符串 $s$ 的后面添加 $k$ 个字符,使得新的字符串 $ss$ 有两个重复的字串,**重复子串必须是相邻的**,求两个重复子串的长度和。 ### 输入格式 输入第一行包括一个字符串 $s$ ( $ 1 \leq |s| \leq 200 $ )。接下来一行输入 $k$ ,表示可在 $s$ 后面添加 $k$ 个字符。 ### 输出格式 输出一个整数,表示两个重复子串的长度和。 ### 样例解释 第一个样例中,添加 $k$ 个字符后是 $aabaab$。 第二个样例中,添加 $k$ 个字符后是 $aaabbbbb$。 第三个样例中,添加 $k$ 个字符后是 $abracadabrabracadabra$。

加入题单

上一题 下一题 算法标签: