結果

問題 No.1250 汝は倍数なりや?
ユーザー lloyzlloyz
提出日時 2022-01-30 18:10:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 1,000 ms
コード長 706 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 110,260 KB
最終ジャッジ日時 2023-09-02 01:44:47
合計ジャッジ時間 8,566 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,988 KB
testcase_01 AC 87 ms
71,916 KB
testcase_02 AC 88 ms
72,060 KB
testcase_03 AC 85 ms
71,928 KB
testcase_04 AC 84 ms
71,676 KB
testcase_05 AC 82 ms
71,720 KB
testcase_06 AC 84 ms
71,788 KB
testcase_07 AC 86 ms
71,552 KB
testcase_08 AC 86 ms
71,784 KB
testcase_09 AC 84 ms
71,832 KB
testcase_10 AC 89 ms
71,916 KB
testcase_11 AC 86 ms
71,780 KB
testcase_12 AC 84 ms
71,748 KB
testcase_13 AC 86 ms
71,908 KB
testcase_14 AC 86 ms
72,128 KB
testcase_15 AC 83 ms
71,792 KB
testcase_16 AC 83 ms
72,136 KB
testcase_17 AC 83 ms
71,940 KB
testcase_18 AC 84 ms
72,068 KB
testcase_19 AC 86 ms
71,836 KB
testcase_20 AC 89 ms
71,908 KB
testcase_21 AC 85 ms
71,868 KB
testcase_22 AC 85 ms
71,852 KB
testcase_23 AC 90 ms
71,864 KB
testcase_24 AC 89 ms
72,140 KB
testcase_25 AC 88 ms
71,788 KB
testcase_26 AC 88 ms
71,676 KB
testcase_27 AC 91 ms
71,856 KB
testcase_28 AC 89 ms
71,632 KB
testcase_29 AC 87 ms
71,844 KB
testcase_30 AC 89 ms
71,908 KB
testcase_31 AC 85 ms
72,028 KB
testcase_32 AC 86 ms
72,060 KB
testcase_33 AC 197 ms
110,260 KB
testcase_34 AC 170 ms
92,900 KB
testcase_35 AC 182 ms
103,524 KB
testcase_36 AC 187 ms
107,004 KB
testcase_37 AC 141 ms
93,380 KB
testcase_38 AC 161 ms
95,388 KB
testcase_39 AC 163 ms
92,816 KB
testcase_40 AC 163 ms
92,916 KB
testcase_41 AC 154 ms
97,692 KB
testcase_42 AC 138 ms
87,736 KB
testcase_43 AC 177 ms
106,740 KB
testcase_44 AC 126 ms
87,716 KB
testcase_45 AC 181 ms
106,992 KB
testcase_46 AC 131 ms
84,588 KB
testcase_47 AC 156 ms
95,072 KB
testcase_48 AC 83 ms
71,864 KB
testcase_49 AC 89 ms
76,956 KB
testcase_50 AC 82 ms
71,708 KB
testcase_51 AC 91 ms
77,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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")
0