結果

問題 No.1731 Product of Subsequence
コンテスト
ユーザー H20
提出日時 2021-12-08 10:38:34
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 458 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 122 ms
コンパイル使用メモリ 85,012 KB
実行使用メモリ 84,612 KB
最終ジャッジ日時 2026-03-30 17:47:43
合計ジャッジ時間 7,963 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import collections
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9+7
for i in range(N):
    A[i] = math.gcd(A[i],K)

DP = collections.defaultdict(int)
DP[1]=1
for a in A:
    NDP = collections.defaultdict(int)
    CDP = DP.copy()

    for k,v in CDP.items():
        gcd = math.gcd(K,a*k)
        NDP[gcd]=(NDP[gcd]+DP[k])%mod
    for k,v in CDP.items():
        NDP[k]=(NDP[k]+DP[k])%mod
    DP = NDP
print(DP[K])
0