300971: CF182D. Common Divisors

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Common Divisors

题意翻译

如果字符串 x 在复制若干次并拼接起来后,可以得到字符串 a,则称 x 是 a 的因子串。例如字符串“abab”的因子串有“ab”以及“abab” 对于给定的两个字符串s1,s2,找出它们的公共“因子串”的个数。

题目描述

Vasya has recently learned at school what a number's divisor is and decided to determine a string's divisor. Here is what he came up with. String $ a $ is the divisor of string $ b $ if and only if there exists a positive integer $ x $ such that if we write out string $ a $ consecutively $ x $ times, we get string $ b $ . For example, string "abab" has two divisors — "ab" and "abab". Now Vasya wants to write a program that calculates the number of common divisors of two strings. Please help him.

输入输出格式

输入格式


The first input line contains a non-empty string $ s_{1} $ . The second input line contains a non-empty string $ s_{2} $ . Lengths of strings $ s_{1} $ and $ s_{2} $ are positive and do not exceed $ 10^{5} $ . The strings only consist of lowercase Latin letters.

输出格式


Print the number of common divisors of strings $ s_{1} $ and $ s_{2} $ .

输入输出样例

输入样例 #1

abcdabcd
abcdabcdabcdabcd

输出样例 #1

2

输入样例 #2

aaa
aa

输出样例 #2

1

说明

In first sample the common divisors are strings "abcd" and "abcdabcd". In the second sample the common divisor is a single string "a". String "aa" isn't included in the answer as it isn't a divisor of string "aaa".

Input

题意翻译

如果字符串 x 在复制若干次并拼接起来后,可以得到字符串 a,则称 x 是 a 的因子串。例如字符串“abab”的因子串有“ab”以及“abab” 对于给定的两个字符串s1,s2,找出它们的公共“因子串”的个数。

加入题单

上一题 下一题 算法标签: