結果

問題 No.1731 Product of Subsequence
ユーザー ShirotsumeShirotsume
提出日時 2021-11-06 01:08:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 898 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 82,892 KB
実行使用メモリ 91,060 KB
最終ジャッジ日時 2024-04-24 10:30:53
合計ジャッジ時間 25,969 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 52 ms
61,184 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 54 ms
62,080 KB
testcase_08 WA -
testcase_09 AC 95 ms
77,824 KB
testcase_10 TLE -
testcase_11 WA -
testcase_12 AC 96 ms
77,696 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 55 ms
60,416 KB
testcase_16 AC 49 ms
60,288 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 TLE -
testcase_22 WA -
testcase_23 AC 96 ms
77,952 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 96 ms
77,824 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#ぱっと思いつくのはdp[i][j] = i番目まで見て積をkで割ったあまりがjになるものの個数 無理
#Kの約数で考える? K <= 10^9からもそれっぽい
n, k = map(int,input().split())
mod = 10 ** 9 + 7
from collections import Counter
import copy
a = list(map(int,input().split()))
#ありがとう
def div(N):
    ret = []
    for i in range(2, N + 1):
        if i * i > N:
            break
        if N % i == 0:
            ret.append(i)
            if i != N // i:
                ret.append(N // i)
    return ret

d = div(k)
dp = Counter()
for i in d:
    dp[i] = 0
dp[1] = 1
from math import gcd
for i in range(n):
    E = copy.copy(dp)
    dp = Counter()
    for v in E.keys():
        dp[gcd(k, v * a[i])] += E[v]
        dp[v] += E[v]
        dp[gcd(k, v * a[i])] %= mod
        dp[v] %= mod

print((dp[k] + dp[0] - 1 if k == 1 else 0) % mod)


        


0