結果

問題 No.1731 Product of Subsequence
ユーザー 👑 KazunKazun
提出日時 2021-11-05 21:56:08
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,130 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 89,616 KB
最終ジャッジ日時 2024-04-24 05:42:53
合計ジャッジ時間 25,210 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 38 ms
52,864 KB
testcase_02 AC 39 ms
52,352 KB
testcase_03 AC 42 ms
57,600 KB
testcase_04 AC 41 ms
52,096 KB
testcase_05 AC 59 ms
66,432 KB
testcase_06 AC 51 ms
64,000 KB
testcase_07 AC 42 ms
57,984 KB
testcase_08 AC 128 ms
76,368 KB
testcase_09 WA -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 58 ms
67,968 KB
testcase_13 AC 106 ms
76,912 KB
testcase_14 TLE -
testcase_15 AC 40 ms
52,352 KB
testcase_16 WA -
testcase_17 AC 39 ms
52,224 KB
testcase_18 AC 1,861 ms
83,284 KB
testcase_19 AC 97 ms
76,816 KB
testcase_20 AC 1,534 ms
81,792 KB
testcase_21 TLE -
testcase_22 AC 76 ms
76,404 KB
testcase_23 WA -
testcase_24 AC 111 ms
76,496 KB
testcase_25 AC 84 ms
76,596 KB
testcase_26 AC 423 ms
77,316 KB
testcase_27 AC 585 ms
77,184 KB
testcase_28 AC 1,213 ms
79,744 KB
testcase_29 AC 443 ms
76,928 KB
testcase_30 TLE -
testcase_31 AC 68 ms
74,352 KB
testcase_32 WA -
testcase_33 AC 69 ms
73,472 KB
testcase_34 AC 181 ms
76,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)

    if N&1==0:
        C=0
        while N&1==0:
            N>>=1
            C+=1
        R.append([2,C])

    if N%3==0:
        C=0
        while N%3==0:
            N//=3
            C+=1
        R.append([3,C])

    k=5
    Flag=0
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=2+2*Flag
        Flag^=1

    if N!=1:
        R.append([N,1])

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

Mod=10**9+7

P=[(p,e) for p,e in Prime_Factorization(K)]

m=len(P)
DP={(0,)*m:1}

for a in A:
    E=DP.copy()

    f=[0]*m
    for i in range(m):
        p,_=P[i]
        while a%p==0:
            f[i]+=1
            a//=p

    for u in E:
        v=list(u)
        for i in range(m):
            v[i]=min(u[i]+f[i],P[i][1])
        DP[tuple(v)]=(DP.get(tuple(v),0)+E[u])%Mod

end=tuple([e for p,e in P])
print(DP.get(end,0))
0