結果

問題 No.1731 Product of Subsequence
ユーザー 👑 KazunKazun
提出日時 2021-11-05 23:03:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 911 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 77,524 KB
最終ジャッジ日時 2024-04-25 17:33:49
合計ジャッジ時間 11,605 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 741 ms
77,228 KB
testcase_01 AC 35 ms
52,700 KB
testcase_02 AC 35 ms
53,484 KB
testcase_03 AC 38 ms
58,996 KB
testcase_04 AC 37 ms
54,152 KB
testcase_05 AC 40 ms
60,060 KB
testcase_06 AC 41 ms
59,572 KB
testcase_07 AC 36 ms
57,716 KB
testcase_08 AC 74 ms
68,568 KB
testcase_09 AC 37 ms
60,228 KB
testcase_10 AC 911 ms
77,524 KB
testcase_11 AC 770 ms
77,100 KB
testcase_12 AC 49 ms
65,176 KB
testcase_13 AC 73 ms
76,204 KB
testcase_14 AC 696 ms
77,092 KB
testcase_15 AC 37 ms
53,052 KB
testcase_16 AC 36 ms
53,872 KB
testcase_17 AC 36 ms
52,540 KB
testcase_18 AC 797 ms
77,500 KB
testcase_19 AC 74 ms
76,372 KB
testcase_20 AC 627 ms
77,112 KB
testcase_21 AC 902 ms
77,316 KB
testcase_22 AC 666 ms
77,452 KB
testcase_23 AC 37 ms
59,376 KB
testcase_24 AC 59 ms
64,780 KB
testcase_25 AC 52 ms
63,980 KB
testcase_26 AC 207 ms
76,380 KB
testcase_27 AC 261 ms
76,416 KB
testcase_28 AC 485 ms
76,532 KB
testcase_29 AC 218 ms
76,352 KB
testcase_30 AC 787 ms
77,232 KB
testcase_31 AC 637 ms
77,040 KB
testcase_32 AC 36 ms
58,808 KB
testcase_33 AC 95 ms
76,352 KB
testcase_34 AC 116 ms
76,588 KB
権限があれば一括ダウンロードができます

ソースコード

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