#yukicoder2954 Calculation of Exponentiation #入力受取 A, B = input().split() from decimal import Decimal, getcontext def brute(A, B): getcontext().prec = 3000 C = pow( Decimal(A), Decimal(B) ) return round(C, 2000) == round(C) #ノックダウンあり def solve(A, B): #1. A, Bを A / 10000 の形に変更 convert = lambda S: int( S.replace( '.', '' ) ) C, D = convert(A), convert(B) #2. コーナーケースを処理 if B == 0: return True #3. A = C / 10000 = P / Q の形に変換。Q != 1 ならFalse gcd = lambda x, y: gcd(y, x % y) if y else abs(x) P, Q = C // gcd(C, 10000), 10000 // gcd(C, 10000) if Q != 1: return False #4. Pを素因数分解 F = [] x = P for p in range(2, x + 1): if p ** 2 > x: break if ( x % p == 0 ) and ( c := 0 ) == 0: while x % p == 0 < ( c := c + 1 ): x //= p F.append((x, c)) if x > 1: F.append((x, 1)) #5. P = Π(Pi ** Ei) に対して、Ei * (D / 10000) がすべて非負整数ならTrue for Pi, Ei in F: if Ei * D % 10000 == 0 and Ei * D // 10000 >= 0: continue else: return False else: return True print( 'Yes' if solve(A, B) else 'No' )