結果

問題 No.1731 Product of Subsequence
ユーザー 👑 KazunKazun
提出日時 2021-11-05 23:03:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,005 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2024-11-08 04:51:24
合計ジャッジ時間 12,963 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

def Divisors(N):
    N=abs(N)
    L,U=[],[]
    k=1
    while k*k <=N:
        if N%k== 0:
            L.append(k)
            if k*k!=N:
                U.append(N//k)
        k+=1
    return L+U[::-1]
#==================================================
from math import gcd

N,K=map(int,input().split())
A=list(map(int,input().split()))

Mod=10**9+7

if K==1:
    exit(print((pow(2,N,Mod)-1)%Mod))

D=Divisors(K)[::-1]
DP={d:0 for d in D}; DP[1]=1

for a in A:
    for d in D:
        DP[gcd(a*d,K)]+=DP[d]

    for d in D:
        DP[d]%=Mod

print(DP[K])
0