Common Divisors
Xem dạng PDF
Gửi bài giải
Điểm:
5,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
512M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Reference: Codeforces 182D — Common Divisors
A string ~a~ is called a divisor of a string ~b~ if there exists a positive integer ~x~ such that writing ~a~ exactly ~x~ consecutive times produces ~b~.
For example, the string abab has two divisors:
ab
abab
You are given two non-empty strings ~s_1~ and ~s_2~.
Find the number of strings that are divisors of both ~s_1~ and ~s_2~.
Input
- The first line contains the string ~s_1~.
- The second line contains the string ~s_2~.
Output
- Print the number of common divisors of the two strings.
Constraints
- ~1 \le |s_1|, |s_2| \le 10^5~
- Both strings contain only lowercase English letters.
Example 1
Input:
abcdabcd
abcdabcdabcdabcd
Output:
2
Bình luận