結果

問題 No.1250 汝は倍数なりや?
ユーザー shotoyooshotoyoo
提出日時 2020-10-09 22:08:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 175 ms / 1,000 ms
コード長 1,356 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 101,712 KB
最終ジャッジ日時 2023-09-27 17:25:32
合計ジャッジ時間 8,267 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
72,164 KB
testcase_01 AC 92 ms
72,092 KB
testcase_02 AC 92 ms
71,976 KB
testcase_03 AC 91 ms
71,904 KB
testcase_04 AC 93 ms
72,128 KB
testcase_05 AC 91 ms
71,936 KB
testcase_06 AC 91 ms
72,124 KB
testcase_07 AC 92 ms
71,912 KB
testcase_08 AC 93 ms
72,060 KB
testcase_09 AC 93 ms
71,836 KB
testcase_10 AC 94 ms
72,056 KB
testcase_11 AC 93 ms
71,876 KB
testcase_12 AC 92 ms
71,756 KB
testcase_13 AC 92 ms
72,084 KB
testcase_14 AC 92 ms
72,096 KB
testcase_15 AC 92 ms
72,204 KB
testcase_16 AC 92 ms
72,192 KB
testcase_17 AC 91 ms
72,024 KB
testcase_18 AC 93 ms
71,692 KB
testcase_19 AC 91 ms
72,088 KB
testcase_20 AC 93 ms
72,128 KB
testcase_21 AC 93 ms
71,576 KB
testcase_22 AC 93 ms
71,916 KB
testcase_23 AC 93 ms
72,124 KB
testcase_24 AC 100 ms
77,360 KB
testcase_25 AC 101 ms
77,360 KB
testcase_26 AC 101 ms
77,892 KB
testcase_27 AC 100 ms
77,260 KB
testcase_28 AC 100 ms
77,252 KB
testcase_29 AC 94 ms
71,872 KB
testcase_30 AC 100 ms
77,372 KB
testcase_31 AC 93 ms
71,916 KB
testcase_32 AC 102 ms
77,768 KB
testcase_33 AC 174 ms
101,048 KB
testcase_34 AC 157 ms
94,752 KB
testcase_35 AC 160 ms
101,712 KB
testcase_36 AC 175 ms
99,452 KB
testcase_37 AC 134 ms
94,512 KB
testcase_38 AC 138 ms
96,668 KB
testcase_39 AC 166 ms
94,864 KB
testcase_40 AC 157 ms
94,908 KB
testcase_41 AC 131 ms
98,200 KB
testcase_42 AC 131 ms
88,224 KB
testcase_43 AC 170 ms
99,400 KB
testcase_44 AC 124 ms
88,096 KB
testcase_45 AC 161 ms
99,592 KB
testcase_46 AC 124 ms
84,104 KB
testcase_47 AC 159 ms
96,536 KB
testcase_48 AC 91 ms
71,468 KB
testcase_49 AC 91 ms
71,844 KB
testcase_50 AC 92 ms
71,852 KB
testcase_51 AC 91 ms
72,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,h = list(map(int, input().split()))
a = list(map(int, input().split()))
def hurui(n):
    pl = []
    mpf = [None]*(n+1)
    for d in range(2,n):
        if mpf[d] is None:
            mpf[d] = d
            pl.append(d)
        for p in pl:
            if p*d>n or p>mpf[d]:
                break
            mpf[p*d] = p
    return pl, mpf
from collections import defaultdict
def factor2(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    f = {}
    tmp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M+1):
        if tmp<i:
            break
        if tmp%i==0:
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp //= i
            f[i] = cnt
    if tmp!=1:
        f[tmp] = 1
    if not f:
        f[n] = 1
    return f

if 0 in a or h==1:
    ans = "YES"
else:
    d2 = factor2(h)
    d = defaultdict(int)
    for num in a:
        for k in d2.keys():
            while num % k == 0:
                num //= k
                d[k] += 1
    if all(d2[k]<=d[k] for k in d2.keys()):
        ans = "YES"
    else:
        ans = "NO"
print(ans)
0