結果

問題 No.1731 Product of Subsequence
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-11-05 21:55:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,173 ms / 2,000 ms
コード長 906 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 83,572 KB
最終ジャッジ日時 2024-04-25 17:21:42
合計ジャッジ時間 10,542 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,071 ms
80,316 KB
testcase_01 AC 34 ms
52,816 KB
testcase_02 AC 34 ms
53,768 KB
testcase_03 AC 38 ms
58,200 KB
testcase_04 AC 36 ms
52,816 KB
testcase_05 AC 50 ms
65,516 KB
testcase_06 AC 48 ms
64,884 KB
testcase_07 AC 37 ms
58,600 KB
testcase_08 AC 78 ms
76,688 KB
testcase_09 AC 38 ms
59,552 KB
testcase_10 AC 623 ms
79,908 KB
testcase_11 AC 550 ms
79,520 KB
testcase_12 AC 50 ms
66,428 KB
testcase_13 AC 85 ms
77,144 KB
testcase_14 AC 450 ms
78,824 KB
testcase_15 AC 35 ms
53,440 KB
testcase_16 AC 36 ms
53,420 KB
testcase_17 AC 35 ms
52,864 KB
testcase_18 AC 911 ms
81,372 KB
testcase_19 AC 94 ms
77,124 KB
testcase_20 AC 719 ms
79,740 KB
testcase_21 AC 592 ms
79,808 KB
testcase_22 AC 65 ms
74,280 KB
testcase_23 AC 41 ms
58,832 KB
testcase_24 AC 84 ms
76,784 KB
testcase_25 AC 74 ms
76,916 KB
testcase_26 AC 155 ms
77,228 KB
testcase_27 AC 186 ms
77,212 KB
testcase_28 AC 381 ms
77,180 KB
testcase_29 AC 168 ms
76,980 KB
testcase_30 AC 1,173 ms
83,572 KB
testcase_31 AC 60 ms
71,112 KB
testcase_32 AC 37 ms
58,424 KB
testcase_33 AC 60 ms
70,112 KB
testcase_34 AC 106 ms
77,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9+7
if k == 1:
    print((pow(2,n,mod)-1)%mod)
    exit()
div = []
dnum = []
num = k

for i in range(2,int(k**0.5)+1):
    if num%i:
        continue
    count = 0
    while num%i == 0:
        num //= i
        count += 1
    div.append(i)
    dnum.append(count)
if num != 1:
    div.append(num)
    dnum.append(1)
l = len(div)
dic = {k:1}
for a in A:
    cand = [0]*l
    for i,d in enumerate(div):
        while a%d == 0:
            a //= d
            cand[i] += 1
    ndic = {}
    for x,v in dic.items():
        nex = x
        for i in range(l):
            for j in range(cand[i]):
                if nex%div[i] == 0:
                    nex //= div[i]
                else:
                    break
        ndic[nex] = (ndic.get(nex,0)+v)%mod
        ndic[x] = (ndic.get(x,0)+v)%mod
    dic = ndic

print(dic.get(1,0))
0