CF182D.Common Divisors

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 aa is the divisor of string bb if and only if there exists a positive integer xx such that if we write out string aa consecutively xx times, we get string bb . 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 s1s_{1} .

The second input line contains a non-empty string s2s_{2} .

Lengths of strings s1s_{1} and s2s_{2} are positive and do not exceed 10510^{5} . The strings only consist of lowercase Latin letters.

输出格式

Print the number of common divisors of strings s1s_{1} and s2s_{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".

首页