F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

MZL's Circle Zhou

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 785    Accepted Submission(s): 313


Problem Description
MZL's Circle Zhou is good at solving some counting problems. One day, he comes up with a counting problem:
You are given two strings $a,b$ which consist of only lowercase English letters. You can subtract a substring $x$ (maybe empty) from string $a$ and a substring $y$ (also maybe empty) from string $b$, and then connect them as $x+y$ with $x$ at the front and $y$ at the back. In this way, a series of new strings can be obtained.
The question is how many different new strings can be obtained in this way.
Two strings are different, if and only if they have different lengths or there exists an integer $i$ such that the two strings have different characters at position $i$.
 

Input
The first line of the input is a single integer $T~(T¡Ü5)$, indicating the number of testcases.
For each test case, there are two lines, the first line is string $a$, and the second line is string $b$. $1<=|a|,|b|<=90000$.
 

Output
For each test case, output one line, a single integer indicating the answer.
 

Sample Input
2 acbcc cccabc bbbabbababbababbaaaabbbbabbaaaabaabbabbabbbaaabaab abbaabbabbaaaabbbaababbabbabababaaaaabbaabbaabbaab
 

Sample Output
135 557539
 

Author
SXYZ
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-04 18:16:09, Gzip enabled