## https://yukicoder.me/problems/no/2954 import math def calc_gcd(A, B): """ 正の整数A, Bの最大公約数を計算する """ a = max(A, B) b = min(A, B) while a % b > 0: c = a % b a = b b = c return b def decompose_rational(A:str): p, q = A.split(".") sign = 1 if p.startswith("-"): sign = -1 p = p[1:] p_ = int(p) * 10000 + int(q) q_ = 10000 gcd = calc_gcd(p_, q_) return sign, p_ // gcd, q_ // gcd def primal_decompose(A): sqrt_a = int(math.sqrt(A)) primes = {} for p in range(2, sqrt_a + 1): if A % p == 0: primes[p] = 0 while A % p == 0: primes[p] += 1 A //= p if A > 1: primes[A] = 1 return primes def main(): A, B = input().split() _, a_p, a_q = decompose_rational(A) b_sign, b_p, b_q = decompose_rational(B) if b_p == 0: # 0乗は常に1 print("Yes") elif b_sign == 1: if a_q > 1: print("No") return else: # a_pの素因数分解 # 全ての素数の指数がb_qで割り切れるかどうか primes = primal_decompose(a_p) for v in primes.values(): if v % b_q != 0: print("No") return print("Yes") else: if a_p > 1: print("No") return else: # a_qの素因数分解 # 全ての素数の指数がb_pで割り切れるかどうか primes = primal_decompose(a_q) for v in primes.values(): if v % b_p != 0: print("No") return print("Yes") if __name__ == "__main__": main()