結果

問題 No.1731 Product of Subsequence
ユーザー ygd.
提出日時 2021-11-07 16:28:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 519 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 82,480 KB
実行使用メモリ 123,840 KB
最終ジャッジ日時 2024-11-14 03:06:18
合計ジャッジ時間 23,989 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 WA * 24 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline
import math
import copy
from collections import defaultdict 


def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    #dp[v]:vで割れる値
    dp = defaultdict(int)
    dp[1] = 1
    for i,a in enumerate(A):
        p = copy.deepcopy(dp)
        p,dp = dp,p
        for v in p:
            nv = math.gcd(K,v*a)
            dp[nv] += p[v]
    ans = dp[K]
    print(ans)

if __name__ == '__main__':
    main()
0