結果

問題 No.1731 Product of Subsequence
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-11-05 21:55:39
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,288 ms / 2,000 ms
コード長 906 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 84,996 KB
最終ジャッジ日時 2023-08-07 23:05:55
合計ジャッジ時間 12,389 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,123 ms
81,548 KB
testcase_01 AC 70 ms
71,388 KB
testcase_02 AC 71 ms
71,792 KB
testcase_03 AC 74 ms
76,160 KB
testcase_04 AC 71 ms
71,528 KB
testcase_05 AC 85 ms
76,804 KB
testcase_06 AC 82 ms
76,688 KB
testcase_07 AC 74 ms
75,652 KB
testcase_08 AC 112 ms
77,744 KB
testcase_09 AC 75 ms
75,372 KB
testcase_10 AC 660 ms
80,912 KB
testcase_11 AC 578 ms
80,736 KB
testcase_12 AC 88 ms
76,884 KB
testcase_13 AC 119 ms
77,856 KB
testcase_14 AC 502 ms
79,800 KB
testcase_15 AC 73 ms
71,672 KB
testcase_16 AC 70 ms
71,188 KB
testcase_17 AC 73 ms
71,684 KB
testcase_18 AC 978 ms
82,336 KB
testcase_19 AC 129 ms
77,996 KB
testcase_20 AC 777 ms
80,788 KB
testcase_21 AC 647 ms
80,884 KB
testcase_22 AC 103 ms
78,144 KB
testcase_23 AC 74 ms
75,544 KB
testcase_24 AC 114 ms
77,948 KB
testcase_25 AC 107 ms
77,944 KB
testcase_26 AC 192 ms
78,012 KB
testcase_27 AC 224 ms
78,276 KB
testcase_28 AC 418 ms
78,188 KB
testcase_29 AC 198 ms
78,172 KB
testcase_30 AC 1,288 ms
84,996 KB
testcase_31 AC 100 ms
76,992 KB
testcase_32 AC 75 ms
75,360 KB
testcase_33 AC 97 ms
77,084 KB
testcase_34 AC 144 ms
77,932 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