結果
| 問題 |
No.1731 Product of Subsequence
|
| コンテスト | |
| ユーザー |
taiga0629kyopro
|
| 提出日時 | 2022-09-16 18:31:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 429 bytes |
| コンパイル時間 | 345 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 178,432 KB |
| 最終ジャッジ日時 | 2024-12-21 15:28:16 |
| 合計ジャッジ時間 | 13,565 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 WA * 12 |
ソースコード
from math import gcd
from _collections import defaultdict
mod=10**9+7
n,k=map(int,input().split())
if k==1:
print((2**n-1)%mod)
exit()
a=[0]+list(map(int,input().split()))
for i in range(1,n+1):
a[i]=gcd(a[i],k)
dp=[defaultdict(int) for i in range(n+3)]
dp[0][1]=1
for i in range(n):
for j in dp[i]:
dp[i][j]%=mod
dp[i+1][j]+=dp[i][j]
dp[i+1][gcd(k,j*a[i+1])]+=dp[i][j]
print(dp[n][k])
taiga0629kyopro