結果
問題 | No.1723 [Cherry 3rd Tune *] Dead on |
ユーザー |
|
提出日時 | 2022-10-26 19:21:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 399 ms / 2,000 ms |
コード長 | 1,012 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-04 08:07:25 |
合計ジャッジ時間 | 5,909 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
from itertools import count def calc_prime_factorize(num: int) -> dict[int, int]: if num < 2: raise ValueError divisors = {} for divisor in count(2): if divisor ** 2 > num: if num != 1: divisors[num] = 1 break while num % divisor == 0 and num != 1: try: divisors[divisor] += 1 except KeyError: divisors[divisor] = 1 num //= divisor return divisors def main(): X, A, Y, B = map(int, input().split()) if Y == 1: print("Yes") return if X == 1: print("No") return X_factors = calc_prime_factorize(X) Y_factors = calc_prime_factorize(Y) for y_prime, count_ in Y_factors.items(): if y_prime not in X_factors: print("No") return if X_factors[y_prime]*A < count_ * B: print("No") return print("Yes") if __name__ == "__main__": main()