시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 (추가 시간 없음) | 512 MB | 52 | 36 | 27 | 75.000% |
A divisor of string $A$ is a string $D$ which can be repeated an integer number of times to obtain $A$. For example, divisors of string "aaaa
" are strings "a
", "aa
", and "aaaa
", and divisors of string "ababab
" are strings "ab
" and "ababab
".
Consider two strings $S$ and $T$. Find the shortest of strings which are simultaneously divisors of $S$ and divisors of $T$, or determine that there are no such strings.
The first line contains string $S$, and the second line contains string $T$. Each of these strings has length from $1$ to $50$ characters, inclusive, and consists only of lowercase English letters.
Print the least common divisor of strings $S$ and $T$, or the string "No solution
" in case the least common divisor does not exist.
abab ababab
ab
aaaa aaaa
a
abc de
No solution