結果

問題 No.1250 汝は倍数なりや?
ユーザー wattaihei
提出日時 2020-10-09 21:36:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 930 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2024-07-20 09:45:31
合計ジャッジ時間 3,696 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 TLE * 1 -- * 30
権限があれば一括ダウンロードができます

ソースコード

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()))

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