#P4656. Equivalent Strings
Equivalent Strings
Equivalent Strings
题面翻译
给定两个字符串,询问它们是不是等价的(,等效的,等价的)。
关于等价的定义:(以字符串为例)
- 如果为奇数,那与等价的字符串为它本身;
- 如果为偶数,那把平分为两份,记作,与等价的字符串为或
题目描述
Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings and of equal length are called equivalent in one of the two cases:
- They are equal.
- If we split string into two halves of the same size and , and string into two halves of the same size and , then one of the following is correct:
- is equivalent to , and is equivalent to
- is equivalent to , and is equivalent to
As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent.
Gerald has already completed this home task. Now it's your turn!
输入格式
The first two lines of the input contain two strings given by the teacher. Each of them has the length from to and consists of lowercase English letters. The strings have the same length.
输出格式
Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise.
样例 #1
样例输入 #1
aaba
abaa
样例输出 #1
YES
样例 #2
样例输入 #2
aabb
abab
样例输出 #2
NO
提示
In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a".
In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa".