CF443B.Kolya and Tandem Repeat

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Kolya got string ss for his birthday, the string consists of small English letters. He immediately added kk more characters to the right of the string.

Then Borya came and said that the new string contained a tandem repeat of length ll as a substring. How large could ll be?

See notes for definition of a tandem repeat.

输入格式

The first line contains ss ( 1<=s<=2001<=|s|<=200 ). This string contains only small English letters. The second line contains number kk ( 1<=k<=2001<=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 2n2n is string ss , where for any position ii ( 1<=i<=n1<=i<=n ) the following condition fulfills: si=si+ns_{i}=s_{i+n} .

In the first sample Kolya could obtain a string aabaab, in the second — aaabbbbbb, in the third — abracadabrabracadabra.

首页