CF314B.Sereja and Periods

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Let's introduce the designation , where xx is a string, nn is a positive integer and operation " ++ " is the string concatenation operation. For example, [abc,2]=abcabc[abc,2]=abcabc .

We'll say that string ss can be obtained from string tt , if we can remove some characters from string tt and obtain string ss . For example, strings abab and aсbaaсba can be obtained from string xacbacxacbac , and strings bxbx and aaaaaa cannot be obtained from it.

Sereja has two strings, w=[a,b]w=[a,b] and q=[c,d]q=[c,d] . He wants to find such maximum integer pp (p>0) , that [q,p][q,p] can be obtained from string ww .

输入格式

The first line contains two integers bb , dd (1<=b,d<=107)(1<=b,d<=10^{7}) . The second line contains string aa . The third line contains string cc . The given strings are not empty and consist of lowercase English letters. Their lengths do not exceed 100100 .

输出格式

In a single line print an integer — the largest number pp . If the required value of pp doesn't exist, print 0.

输入输出样例

  • 输入#1

    10 3
    abab
    bab
    

    输出#1

    3
    
首页