Back to problems Sign in to unlock
Codeforces
Easy
Math
Number Theory
Cifera
Determine whether one number is a power multiple of another by repeatedly multiplying and checking divisibility.
Acceptance 0%
Problem Statement
Problem
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.
Input Format
- The first line contains two integers and .
Output Format
- Print
YESif is a power of . - Otherwise, print
NO.
Constraints
Hints
- Repeatedly divide by while it is divisible.
- If the process ends at $1ba$.
Input Format
- One line with two integers and .
Output Format
- Output
YESif is a power of $a, otherwise outputNO`.
Constraints
Examples
Sample cases returned by the problem API.
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
Unlock deeper context for this problem
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.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.