首页 > 试题广场 >

CodeForces 114D Petr#

[编程题]CodeForces 114D Petr#
  • 热度指数:6 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解

Long ago, when Petya was a schoolboy, he was very much interested in the Petr# language grammar. During one lesson Petya got interested in the following question: how many different continuous substrings starting with the s begin and ending with the s end (it is possible s begin  = s end ), the given string t has. Substrings are different if and only if their contents aren't equal, their positions of occurence don't matter. Petya wasn't quite good at math, that's why he couldn't count this number. Help him!


输入描述:

The input file consists of three lines. The first line contains string t. The second and the third lines contain the sbegin and send identificators, correspondingly. All three lines are non-empty strings consisting of lowercase Latin letters. The length of each string doesn't exceed 2000 characters.



输出描述:

Output the only number — the amount of different substrings of t that start with sbegin and end with send.

示例1

输入

round
ro
ou
codeforces
code
forca
abababab
a
b
aba
ab
ba

输出

1
0
4
1

备注:

In the third sample there are four appropriate different substrings. They are: ab, abab, ababab, abababab.

In the fourth sample identificators intersect.

这道题你会答吗?花几分钟告诉大家答案吧!