测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A9508. 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.
上一题 去做题 下一题