Determine whether one number is a power multiple of another by repeatedly multiplying and checking divisibility.
You are given two positive integers and . Determine whether there exists a non-negative integer such that
If such a exists, the numbers are related; otherwise, they are not.
In practice, this means you should verify whether can be obtained by starting from and repeatedly multiplying by until reaching exactly.
YES if is a power of .NO.YES if is a power of $a, otherwise output NO`.Example 1
Input
2 8
Output
YES
Explanation
Since , the answer is YES.
Example 2
Input
3 10
Output
NO
Explanation
No integer power of $3 equals \10`.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.