結果
問題 |
No.1731 Product of Subsequence
|
ユーザー |
![]() |
提出日時 | 2021-11-05 22:34:48 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 878 bytes |
コンパイル時間 | 243 ms |
コンパイル使用メモリ | 82,468 KB |
実行使用メモリ | 373,752 KB |
最終ジャッジ日時 | 2024-11-06 13:34:00 |
合計ジャッジ時間 | 6,674 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | TLE * 1 -- * 30 |
ソースコード
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def IR(n): return [I() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 def solve(): n,k = LI() a = [i%k for i in LI()] dp = defaultdict(lambda : 0) dp[1] = 1 for i in a: dp_ = list(dp.items()) for j,v in dp_: if not v: continue ni = i*j if ni >= k: ni %= k dp[ni] += v if dp[ni] >= mod: dp[ni] -= mod print(dp[0]) return if __name__ == "__main__": solve()