#P7050. [NWRRC2015] Concatenation

[NWRRC2015] Concatenation

题目描述

Famous programmer Gennady likes to create new words. One way to do it is to concatenate existing words. That means writing one word after another. For example, if he has words cat and dog, he would get a word catdog, that could mean something like the name of a creature with two heads: one cat head and one dog head.

Gennady is a bit bored of this way of creating new words, so he has invented another method. He takes a non-empty prefix of the first word, a non-empty suffix of the second word, and concatenates them. For example, if he has words tree and heap, he can get such words as treap, tap, or theap. Who knows what they could mean?

Gennady chooses two words and wants to know how many different words he can create using his new method. Of course, being a famous programmer, he has already calculated the answer. Can you do the same?

输入格式

Two lines of the input file contain words chosen by Gennady. They have lengths between 11 and 100000100 000 characters and consist of lowercase English letters only.

输出格式

Output one integer -- the number of different words Gennady can create out of words given in the input file.

题目大意

题目描述

著名的程序员 Gennady 喜欢创造新单词。其中一种方法是连接现有单词。

举个例子:如果 Gennady 有 catdog 两个词,那么他会得到一个新词: catdog,这可能意味着带有两个头的生物的名字:一个猫头和一个狗头。

Gennady 觉得这种创建新单词的方式有点无聊,因此他发明了另一种方法:使用第一个单词的非空前缀,第二个单词的非空后缀,并将它们连接起来。例如,如果他有单词 treeheap ,则可以得到诸如 treaptaptheap 之类的单词。

Gennady 选择了两个单词,并想知道他可以使用新方法创建多少个不同的单词。当然,作为著名的程序员,他已经计算出了答案。他突然想考考你,那么你能编写一个程序把答案计算出来吗?

输入格式

两行,每行有一个 Gennady 选择的单词 sis_i1si1000001\leq |s_i| \leq 100000sis_i 仅由小写英文字母组成)。

输出格式

输出一个整数,这个整数表示 Gennady 可以从这两个给定的单词中创建不同单词的数量。

cat
dog

9

tree
heap

14

提示

Time limit: 2 s, Memory limit: 256 MB.