#C9909. Equivalent Encoded Messages
Equivalent Encoded Messages
Equivalent Encoded Messages
You are given two messages s1 and s2, each consisting of uppercase English letters. Each letter is assigned a unique prime number in increasing order (i.e. A=2, B=3, C=5, ..., Z=101). The encoded value of a message is defined as the product of the primes corresponding to its letters.
Due to the unique factorization property, two messages are considered equivalent if and only if they have the same multiset of letters, i.e. the same encoded value. Your task is to determine whether the two given messages are equivalent.
Formally, if the encoded value of s1 is \(\prod_{i=1}^{n} p_{s1_i}\) and that of s2 is \(\prod_{j=1}^{m} p_{s2_j}\), then s1 and s2 are equivalent if and only if the two products are equal.
inputFormat
The input consists of two lines read from standard input. The first line contains the string s1 and the second line contains the string s2. Both strings are composed solely of uppercase English letters.
outputFormat
Output a single line to standard output containing either YES
if the two messages are equivalent, or NO
otherwise.
HELLO
OHLEL
YES