結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー irumo8202
提出日時 2022-02-01 23:47:29
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-11 09:16:20
合計ジャッジ時間 8,070 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

X, A, Y, B = map(int, input().split())
if Y == 1:
    print("Yes")
    exit()


def factorization(n):
    fact = dict()
    temp = n
    for i in range(2, int(-(-(n ** 0.5) // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            fact[i] = cnt

    if temp != 1:
        fact[temp] = 1

    if not fact:
        fact[n] = 1

    return fact


fact_x_power_of_a = {p: cnt * A for p, cnt in factorization(X).items()}
fact_y_power_of_b = {p: cnt * B for p, cnt in factorization(Y).items()}

flg = True
for p in fact_y_power_of_b:
    try:
        if fact_x_power_of_a[p] < fact_y_power_of_b[p]:
            flg = False
    except KeyError:
        flg = False

print("Yes" if flg else "No")
0