結果

問題 No.2682 Visible Divisible
コンテスト
ユーザー Yakumo221
提出日時 2024-03-20 21:48:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
(最新)
TLE  
(最初)
実行時間 1,319 ms / 2,000 ms
コード長 711 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 234 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 110,236 KB
最終ジャッジ日時 2026-04-16 12:26:27
合計ジャッジ時間 7,641 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict

def pf(num):
    
    dic = defaultdict(int)
    i = 2
    while num%i == 0:
        num //= i
        dic[i] += 1
    
    i = 3
    while i*i <= num:
        while num%i == 0:
            num //= i
            dic[i] += 1
        i += 2
    
    if num != 1:
        dic[num] += 1

    return dic

n,k = map(int, input().split())
alist = list(map(int, input().split()))

kdic = pf(k)

que = []
for key, val in kdic.items():
    que.append(pow(key, val))

for a in alist:
    nq = []
    while que:
        v = que.pop()
        if a % v == 0:
            a //= v
        else:
            nq.append(v)
    que = nq

if len(que) == 0:
    print("Yes")
else:
    print("No")
0