結果

問題 No.1731 Product of Subsequence
ユーザー roarisroaris
提出日時 2021-11-05 22:18:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 754 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 78,364 KB
最終ジャッジ日時 2024-04-24 06:07:15
合計ジャッジ時間 12,315 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 808 ms
77,980 KB
testcase_01 AC 43 ms
54,996 KB
testcase_02 AC 43 ms
54,808 KB
testcase_03 AC 45 ms
59,828 KB
testcase_04 AC 43 ms
55,448 KB
testcase_05 AC 52 ms
64,064 KB
testcase_06 AC 49 ms
62,640 KB
testcase_07 AC 46 ms
60,900 KB
testcase_08 AC 90 ms
67,652 KB
testcase_09 WA -
testcase_10 AC 1,085 ms
78,364 KB
testcase_11 AC 924 ms
77,708 KB
testcase_12 AC 56 ms
66,528 KB
testcase_13 AC 87 ms
77,260 KB
testcase_14 AC 840 ms
77,936 KB
testcase_15 AC 43 ms
54,944 KB
testcase_16 WA -
testcase_17 AC 43 ms
54,368 KB
testcase_18 AC 895 ms
78,212 KB
testcase_19 AC 84 ms
77,028 KB
testcase_20 AC 740 ms
77,724 KB
testcase_21 AC 1,083 ms
78,148 KB
testcase_22 AC 272 ms
77,464 KB
testcase_23 WA -
testcase_24 AC 71 ms
66,708 KB
testcase_25 AC 61 ms
66,572 KB
testcase_26 AC 243 ms
77,020 KB
testcase_27 AC 304 ms
77,092 KB
testcase_28 AC 555 ms
76,904 KB
testcase_29 AC 268 ms
76,972 KB
testcase_30 AC 708 ms
77,788 KB
testcase_31 AC 275 ms
77,436 KB
testcase_32 WA -
testcase_33 AC 77 ms
76,688 KB
testcase_34 AC 145 ms
76,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

N, K = map(int, input().split())
A = list(map(int, input().split()))
divs = []

for d in range(1, int(K**0.5)+1):
    if K%d==0:
        divs.append(d)
        
        if d!=K//d:
            divs.append(K//d)

divs.sort()
idx = defaultdict(int)

for i in range(len(divs)):
    idx[divs[i]] = i

M = len(idx.keys())
dp = [0]*M
dp[0] = 1
MOD = 10**9+7

for i in range(N):
    ndp = [0]*M
    
    for j in range(M):
        ndp[j] += dp[j]
        ndp[j] %= MOD
        
        if divs[j]*A[i]%K==0:
            nj = M-1
        else:
            nj = idx[gcd(K, divs[j]*A[i])]
        
        ndp[nj] += dp[j]
        ndp[nj] %= MOD
    
    dp = ndp

print(dp[-1])
0