結果

問題 No.1250 汝は倍数なりや?
ユーザー wattaiheiwattaihei
提出日時 2020-10-09 21:38:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 172 ms / 1,000 ms
コード長 1,015 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 25,784 KB
最終ジャッジ日時 2023-09-27 15:41:22
合計ジャッジ時間 4,010 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
8,456 KB
testcase_01 AC 14 ms
8,392 KB
testcase_02 AC 13 ms
7,944 KB
testcase_03 AC 14 ms
8,256 KB
testcase_04 AC 14 ms
8,256 KB
testcase_05 AC 13 ms
8,452 KB
testcase_06 AC 14 ms
8,220 KB
testcase_07 AC 16 ms
8,148 KB
testcase_08 AC 13 ms
8,264 KB
testcase_09 AC 13 ms
8,432 KB
testcase_10 AC 13 ms
8,256 KB
testcase_11 AC 13 ms
8,444 KB
testcase_12 AC 13 ms
8,208 KB
testcase_13 AC 13 ms
8,260 KB
testcase_14 AC 13 ms
8,216 KB
testcase_15 AC 13 ms
8,440 KB
testcase_16 AC 13 ms
8,216 KB
testcase_17 AC 13 ms
8,208 KB
testcase_18 AC 13 ms
8,260 KB
testcase_19 AC 13 ms
8,312 KB
testcase_20 AC 14 ms
8,072 KB
testcase_21 AC 13 ms
8,364 KB
testcase_22 AC 13 ms
8,440 KB
testcase_23 AC 14 ms
8,068 KB
testcase_24 AC 14 ms
8,208 KB
testcase_25 AC 15 ms
8,456 KB
testcase_26 AC 13 ms
8,316 KB
testcase_27 AC 15 ms
8,320 KB
testcase_28 AC 13 ms
8,232 KB
testcase_29 AC 13 ms
8,228 KB
testcase_30 AC 13 ms
8,196 KB
testcase_31 AC 13 ms
8,408 KB
testcase_32 AC 14 ms
7,996 KB
testcase_33 AC 172 ms
25,784 KB
testcase_34 AC 60 ms
17,084 KB
testcase_35 AC 96 ms
23,456 KB
testcase_36 AC 151 ms
24,244 KB
testcase_37 AC 99 ms
17,596 KB
testcase_38 AC 108 ms
18,332 KB
testcase_39 AC 59 ms
16,896 KB
testcase_40 AC 62 ms
17,312 KB
testcase_41 AC 122 ms
19,980 KB
testcase_42 AC 72 ms
14,616 KB
testcase_43 AC 158 ms
23,900 KB
testcase_44 AC 73 ms
14,564 KB
testcase_45 AC 115 ms
24,372 KB
testcase_46 AC 56 ms
12,648 KB
testcase_47 AC 72 ms
18,308 KB
testcase_48 AC 14 ms
8,256 KB
testcase_49 AC 14 ms
8,312 KB
testcase_50 AC 13 ms
8,392 KB
testcase_51 AC 13 ms
8,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 素因数分解、辞書で返すやつ
import math
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

import sys
input = sys.stdin.buffer.readline
N, H = map(int, input().split())
A = list(map(int, input().split()))

if 0 in A:
    D = {}
else:
    D = prime(H)
    for a in A:
        to_del = []
        for n in D.keys():
            r = 0
            while a % n == 0:
                a //= n
                r += 1
            if D[n] > r:
                D[n] -= r
            else:
                to_del.append(n)

        for d in to_del:
            del D[d]

print("YES" if not D else "NO")
0