結果

問題 No.1250 汝は倍数なりや?
ユーザー kohei2019kohei2019
提出日時 2020-12-17 01:58:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 383 ms / 1,000 ms
コード長 992 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,844 KB
実行使用メモリ 30,632 KB
最終ジャッジ日時 2023-10-20 10:26:26
合計ジャッジ時間 5,847 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,340 KB
testcase_01 AC 30 ms
10,396 KB
testcase_02 AC 30 ms
10,340 KB
testcase_03 AC 30 ms
10,396 KB
testcase_04 AC 30 ms
10,396 KB
testcase_05 AC 31 ms
10,396 KB
testcase_06 AC 30 ms
10,340 KB
testcase_07 AC 30 ms
10,340 KB
testcase_08 AC 30 ms
10,340 KB
testcase_09 AC 30 ms
10,340 KB
testcase_10 AC 30 ms
10,396 KB
testcase_11 AC 30 ms
10,340 KB
testcase_12 AC 31 ms
10,396 KB
testcase_13 AC 30 ms
10,400 KB
testcase_14 AC 30 ms
10,396 KB
testcase_15 AC 31 ms
10,396 KB
testcase_16 AC 30 ms
10,400 KB
testcase_17 AC 29 ms
10,396 KB
testcase_18 AC 29 ms
10,340 KB
testcase_19 AC 29 ms
10,396 KB
testcase_20 AC 31 ms
10,400 KB
testcase_21 AC 29 ms
10,308 KB
testcase_22 AC 30 ms
10,400 KB
testcase_23 AC 31 ms
10,464 KB
testcase_24 AC 31 ms
10,460 KB
testcase_25 AC 31 ms
10,480 KB
testcase_26 AC 30 ms
10,364 KB
testcase_27 AC 32 ms
10,472 KB
testcase_28 AC 30 ms
10,432 KB
testcase_29 AC 30 ms
10,424 KB
testcase_30 AC 29 ms
10,420 KB
testcase_31 AC 30 ms
10,428 KB
testcase_32 AC 30 ms
10,480 KB
testcase_33 AC 383 ms
30,632 KB
testcase_34 AC 72 ms
20,456 KB
testcase_35 AC 107 ms
28,036 KB
testcase_36 AC 326 ms
28,908 KB
testcase_37 AC 215 ms
21,328 KB
testcase_38 AC 240 ms
22,240 KB
testcase_39 AC 68 ms
20,328 KB
testcase_40 AC 74 ms
20,804 KB
testcase_41 AC 269 ms
23,916 KB
testcase_42 AC 159 ms
17,720 KB
testcase_43 AC 343 ms
28,880 KB
testcase_44 AC 165 ms
17,772 KB
testcase_45 AC 179 ms
28,992 KB
testcase_46 AC 128 ms
15,644 KB
testcase_47 AC 102 ms
21,744 KB
testcase_48 AC 29 ms
10,308 KB
testcase_49 AC 31 ms
10,396 KB
testcase_50 AC 30 ms
10,396 KB
testcase_51 AC 32 ms
10,396 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('YES')
    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