結果

問題 No.1731 Product of Subsequence
ユーザー titiatitia
提出日時 2021-11-06 00:55:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,433 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 77,276 KB
最終ジャッジ日時 2024-04-25 17:38:03
合計ジャッジ時間 17,063 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,151 ms
77,276 KB
testcase_01 AC 35 ms
52,952 KB
testcase_02 AC 36 ms
53,524 KB
testcase_03 AC 38 ms
58,200 KB
testcase_04 AC 36 ms
52,924 KB
testcase_05 AC 43 ms
62,764 KB
testcase_06 AC 42 ms
60,540 KB
testcase_07 AC 40 ms
58,772 KB
testcase_08 AC 74 ms
64,764 KB
testcase_09 AC 44 ms
62,236 KB
testcase_10 AC 1,433 ms
77,028 KB
testcase_11 AC 1,185 ms
77,124 KB
testcase_12 AC 50 ms
64,820 KB
testcase_13 AC 83 ms
76,764 KB
testcase_14 AC 1,075 ms
76,884 KB
testcase_15 AC 36 ms
54,000 KB
testcase_16 AC 36 ms
52,896 KB
testcase_17 AC 35 ms
53,828 KB
testcase_18 AC 1,206 ms
77,008 KB
testcase_19 AC 78 ms
76,600 KB
testcase_20 AC 970 ms
77,156 KB
testcase_21 AC 1,417 ms
77,060 KB
testcase_22 AC 931 ms
77,020 KB
testcase_23 AC 44 ms
63,056 KB
testcase_24 AC 58 ms
63,720 KB
testcase_25 AC 52 ms
64,128 KB
testcase_26 AC 289 ms
76,776 KB
testcase_27 AC 364 ms
76,664 KB
testcase_28 AC 710 ms
76,748 KB
testcase_29 AC 304 ms
76,616 KB
testcase_30 AC 1,153 ms
76,996 KB
testcase_31 AC 914 ms
76,676 KB
testcase_32 AC 44 ms
62,500 KB
testcase_33 AC 123 ms
76,556 KB
testcase_34 AC 161 ms
76,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from math import gcd

N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

MAX=int(K**(1/2))

L=[]
for i in range(1,MAX+1):
    if K%i==0:
        L.append(i)
        L.append(K//i)

L=sorted(set(L))
F={L[i]:i for i in range(len(L))}

DP=[0]*len(L)
DP[0]=1

for a in A:
    for i in range(len(L)-1,-1,-1):
        x=L[i]
            
        DP[F[gcd(x*a,K)]]+=DP[i]
        DP[F[gcd(x*a,K)]]%=mod

if K==1:
    print((DP[-1]-1)%mod)
else:
    print(DP[-1])
0