結果

問題 No.1731 Product of Subsequence
ユーザー ygd.ygd.
提出日時 2021-11-07 16:31:45
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,055 ms / 2,000 ms
コード長 673 bytes
コンパイル時間 444 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 83,996 KB
最終ジャッジ日時 2023-08-07 23:35:48
合計ジャッジ時間 13,574 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 856 ms
82,868 KB
testcase_01 AC 112 ms
73,248 KB
testcase_02 AC 113 ms
73,068 KB
testcase_03 AC 113 ms
73,256 KB
testcase_04 AC 113 ms
73,496 KB
testcase_05 AC 121 ms
77,768 KB
testcase_06 AC 119 ms
77,748 KB
testcase_07 AC 114 ms
73,508 KB
testcase_08 AC 142 ms
78,204 KB
testcase_09 AC 116 ms
77,456 KB
testcase_10 AC 1,055 ms
83,544 KB
testcase_11 AC 909 ms
82,592 KB
testcase_12 AC 129 ms
78,308 KB
testcase_13 AC 151 ms
78,828 KB
testcase_14 AC 778 ms
81,844 KB
testcase_15 AC 111 ms
73,232 KB
testcase_16 AC 114 ms
73,208 KB
testcase_17 AC 111 ms
73,108 KB
testcase_18 AC 705 ms
83,976 KB
testcase_19 AC 149 ms
78,956 KB
testcase_20 AC 592 ms
81,592 KB
testcase_21 AC 1,006 ms
83,996 KB
testcase_22 AC 130 ms
78,268 KB
testcase_23 AC 115 ms
77,652 KB
testcase_24 AC 141 ms
78,540 KB
testcase_25 AC 129 ms
78,736 KB
testcase_26 AC 280 ms
78,828 KB
testcase_27 AC 327 ms
79,064 KB
testcase_28 AC 541 ms
79,996 KB
testcase_29 AC 289 ms
78,860 KB
testcase_30 AC 857 ms
82,948 KB
testcase_31 AC 134 ms
78,500 KB
testcase_32 AC 119 ms
77,448 KB
testcase_33 AC 133 ms
78,508 KB
testcase_34 AC 200 ms
78,992 KB
権限があれば一括ダウンロードができます

ソースコード

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()); MOD = pow(10,9) + 7
    A = list(map(int,input().split()))
    if K == 1:
        ans = pow(2,N,MOD) - 1 #一つも選ばないのはダメ
        print(ans);exit()

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

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