当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6068:Classic Quotation

题目描述
When online chatting, we can save what somebody said to form his ''Classic Quotation''. Little Q does this, too. What's more? He even changes the original words. Formally, we can assume what somebody said as a string $S$ whose length is $n$. He will choose a continuous substring of $S$(or choose nothing), and remove it, then merge the remain parts into a complete one without changing order, marked as $S'$. For example, he might remove ''not'' from the string ''I am not SB.'', so that the new string $S'$ will be ''I am SB.'', which makes it funnier.



After doing lots of such things, Little Q finds out that string $T$ occurs as a continuous substring of $S'$ very often.

Now given strings $S$ and $T$, Little Q has $k$ questions. Each question is, given $L$ and $R$, Little Q will remove a substring so that the remain parts are $S[1..i]$ and $S[j..n]$, what is the expected times that $T$ occurs as a continuous substring of $S'$ if he choose every possible pair of $(i,j)(1\leq i\leq L,R\leq j\leq n)$ equiprobably? Your task is to find the answer $E$, and report $E\times L\times (n-R+1)$ to him.

Note : When counting occurrences, $T$ can overlap with each other.
输入解释
The first line of the input contains an integer $C(1\leq C\leq15)$, denoting the number of test cases.

In each test case, there are $3$ integers $n,m,k(1\leq n\leq 50000,1\leq m\leq 100,1\leq k\leq 50000)$ in the first line, denoting the length of $S$, the length of $T$ and the number of questions.

In the next line, there is a string $S$ consists of $n$ lower-case English letters.

Then in the next line, there is a string $T$ consists of $m$ lower-case English letters.

In the following $k$ lines, there are $2$ integers $L,R(1\leq L<R\leq n)$ in each line, denoting a question.
输出解释
For each question, print a single line containing an integer, denoting the answer.
输入样例
1
8 5 4
iamnotsb
iamsb
4 7
3 7
3 8
2 7
输出样例
1
1
0
0
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6068

最后修改于 2020-10-25T23:28:02+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 524288/524288K(Java/Others)