結果

問題 No.1731 Product of Subsequence
ユーザー tassei903tassei903
提出日時 2021-11-06 10:08:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,425 ms / 2,000 ms
コード長 823 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 86,292 KB
最終ジャッジ日時 2023-08-07 23:28:58
合計ジャッジ時間 16,483 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,169 ms
85,568 KB
testcase_01 AC 92 ms
71,504 KB
testcase_02 AC 91 ms
71,864 KB
testcase_03 AC 90 ms
71,784 KB
testcase_04 AC 92 ms
71,672 KB
testcase_05 AC 105 ms
77,540 KB
testcase_06 AC 105 ms
77,528 KB
testcase_07 AC 92 ms
71,740 KB
testcase_08 AC 155 ms
78,176 KB
testcase_09 AC 73 ms
71,388 KB
testcase_10 AC 1,425 ms
85,860 KB
testcase_11 AC 1,188 ms
84,800 KB
testcase_12 AC 113 ms
77,760 KB
testcase_13 AC 179 ms
79,640 KB
testcase_14 AC 1,122 ms
83,916 KB
testcase_15 AC 94 ms
71,644 KB
testcase_16 AC 69 ms
71,004 KB
testcase_17 AC 92 ms
71,784 KB
testcase_18 AC 980 ms
84,684 KB
testcase_19 AC 164 ms
79,008 KB
testcase_20 AC 810 ms
83,316 KB
testcase_21 AC 1,376 ms
86,292 KB
testcase_22 AC 112 ms
77,876 KB
testcase_23 AC 70 ms
71,124 KB
testcase_24 AC 141 ms
78,104 KB
testcase_25 AC 127 ms
78,020 KB
testcase_26 AC 352 ms
79,756 KB
testcase_27 AC 430 ms
79,488 KB
testcase_28 AC 703 ms
80,584 KB
testcase_29 AC 365 ms
78,764 KB
testcase_30 AC 1,210 ms
85,812 KB
testcase_31 AC 117 ms
77,688 KB
testcase_32 AC 74 ms
71,080 KB
testcase_33 AC 120 ms
77,784 KB
testcase_34 AC 255 ms
78,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
mod = 10**9+7
n,k = na()
if k==1:
    print((pow(2,n,mod)-1)%mod)
    exit()
a = na()
from collections import defaultdict
from math import gcd
dp = defaultdict(int)
dp[1] = 1

mod = 10**9+7
for i in range(n):
    p = defaultdict(int)
    p,dp = dp,p
    for j in p:
        nj = gcd(k,j*a[i])
        dp[nj]+=p[j]
        dp[j]+=p[j]
        if dp[nj]>=mod:
            dp[nj]-=mod
        if dp[j]>=mod:
            dp[j]-=mod
print(dp[k])
0