結果
問題 | No.1250 汝は倍数なりや? |
ユーザー |
|
提出日時 | 2022-01-30 18:10:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 167 ms / 1,000 ms |
コード長 | 706 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 101,504 KB |
最終ジャッジ日時 | 2024-06-11 08:22:43 |
合計ジャッジ時間 | 5,767 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
from math import gcd from collections import defaultdict n, h = map(int, input().split()) A = list(map(int, input().split())) H = defaultdict(int) hc = h while h % 2 == 0: H[2] += 1 h //= 2 f = 3 while f * f <= hc: while h % f == 0: H[f] += 1 h //= f f += 2 if h != 1: H[h] += 1 Cnt = defaultdict(int) for i in range(n): r = gcd(A[i], hc) rc = r while r % 2 == 0: Cnt[2] += 1 r //= 2 f = 3 while f * f <= rc: while r % f == 0: Cnt[f] += 1 r //= f f += 2 if r != 1: Cnt[r] += 1 for prime in H.keys(): if H[prime] > Cnt[prime]: print("NO") exit() print("YES")