結果

問題 No.1250 汝は倍数なりや?
ユーザー kohei2019kohei2019
提出日時 2020-12-17 01:57:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 990 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 11,768 KB
実行使用メモリ 30,568 KB
最終ジャッジ日時 2023-10-20 10:26:15
合計ジャッジ時間 6,173 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,288 KB
testcase_01 AC 32 ms
10,352 KB
testcase_02 AC 32 ms
10,288 KB
testcase_03 AC 32 ms
10,352 KB
testcase_04 AC 32 ms
10,352 KB
testcase_05 AC 31 ms
10,352 KB
testcase_06 AC 31 ms
10,288 KB
testcase_07 AC 31 ms
10,288 KB
testcase_08 AC 31 ms
10,288 KB
testcase_09 AC 31 ms
10,288 KB
testcase_10 AC 31 ms
10,352 KB
testcase_11 AC 31 ms
10,288 KB
testcase_12 AC 31 ms
10,352 KB
testcase_13 AC 31 ms
10,356 KB
testcase_14 AC 31 ms
10,352 KB
testcase_15 AC 31 ms
10,352 KB
testcase_16 AC 32 ms
10,356 KB
testcase_17 AC 32 ms
10,352 KB
testcase_18 AC 32 ms
10,288 KB
testcase_19 AC 31 ms
10,352 KB
testcase_20 AC 32 ms
10,356 KB
testcase_21 WA -
testcase_22 AC 32 ms
10,356 KB
testcase_23 AC 33 ms
10,420 KB
testcase_24 AC 33 ms
10,416 KB
testcase_25 AC 33 ms
10,436 KB
testcase_26 AC 32 ms
10,312 KB
testcase_27 AC 34 ms
10,428 KB
testcase_28 AC 32 ms
10,388 KB
testcase_29 AC 32 ms
10,380 KB
testcase_30 AC 32 ms
10,368 KB
testcase_31 AC 31 ms
10,384 KB
testcase_32 AC 32 ms
10,436 KB
testcase_33 AC 391 ms
30,568 KB
testcase_34 AC 76 ms
20,392 KB
testcase_35 AC 111 ms
27,972 KB
testcase_36 AC 339 ms
28,844 KB
testcase_37 AC 232 ms
21,264 KB
testcase_38 AC 259 ms
22,176 KB
testcase_39 AC 73 ms
20,264 KB
testcase_40 AC 80 ms
20,740 KB
testcase_41 AC 278 ms
23,852 KB
testcase_42 AC 169 ms
17,656 KB
testcase_43 AC 349 ms
28,816 KB
testcase_44 AC 167 ms
17,708 KB
testcase_45 AC 184 ms
28,928 KB
testcase_46 AC 134 ms
15,580 KB
testcase_47 AC 107 ms
21,680 KB
testcase_48 AC 31 ms
10,256 KB
testcase_49 AC 34 ms
10,352 KB
testcase_50 AC 33 ms
10,352 KB
testcase_51 AC 34 ms
10,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import copy
N,H = map(int,input().split())
lsA = list(map(int,input().split()))
def factorization(a):#素因数分解√N
    arr = []
    temp = a
    for i in range(2, int(-(-a**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([a, 1])
    return arr #[素因数、個数]
if 0 in lsA:
    print('NO')
    sys.exit()
if H == 1:
    print('YES')
    sys.exit()
lsp = factorization(H)
for i in range(N):
    if not lsp:
        print('YES')
        sys.exit()
    k = lsA[i]
    for j in range(len(lsp)):
        p = lsp[j][0]
        while k % p == 0:
            lsp[j][1] -= 1
            k //= p
    lsp2 = []
    for j in range(len(lsp)):
        if lsp[j][1] > 0:
            lsp2.append(lsp[j])
    lsp = copy.copy(lsp2)
if not lsp:
    print('YES')
    sys.exit()
print('NO')
0