from math import gcddef reduce(a, b): k = gcd(a, b) return a // k, b // kdef take2s(b: int) -> int: return b if b % 2 != 0 else take2s(b // 2)def take5s(b: int) -> int: return b if b % 5 != 0 else take5s(b // 5)def take10s(b: int) -> int: return take5s(take2s(b))def isFinie(b: int) -> bool: return take10s(b) == 1a, b = int(input()), int(input())a, b = reduce(a, b)print("yes" if isFinie(b) else "no")
Python 3.8.3
Код:
from math import gcddef reduce(a, b): k = gcd(a, b) return a // k, b // kdef take2s(b: int) -> int: return b if b % 2 != 0 else take2s(b // 2)def take5s(b: int) -> int: return b if b % 5 != 0 else take5s(b // 5)def take10s(b: int) -> int: return take5s(take2s(b))def isFinie(b: int) -> bool: return take10s(b) == 1a, b = int(input()), int(input())a, b = reduce(a, b)print("yes" if isFinie(b) else "no")