Common Substrings

TimeLimit:5000MS  MemoryLimit:65536K
64-bit integer IO format:%lld
未提交 | 登录后收藏
Problem Description

A substring of a string T is defined as:

T( i, k)= TiTi +1... Ti+k -1, 1≤ ii+k-1≤| T|.

Given two strings A, B and one integer K, we define S, a set of triples (i, j, k):

S = {( i, j, k) | kK, A( i, k)= B( j, k)}.

You are to give the value of |S| for specific A, B and K.

Input

The input file contains several blocks of data. For each block, the first line contains one integer K, followed by two lines containing strings A and B, respectively. The input file is ended by K=0.

1 ≤ |A|, |B| ≤ 105
1 ≤ Kmin{|A|, |B|}
Characters of A and B are all Latin letters.

Output

For each case, output an integer |S|.

SampleInput
2
aababaa
abaabaa
1
xx
xx
0
SampleOutput
22
5
Submit
题目统计信息详细
总AC数2
通过人数1
尝试人数1
总提交量2
AC率50.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: