結果

問題 No.1731 Product of Subsequence
ユーザー puznekopuzneko
提出日時 2021-11-20 01:16:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 780 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 87,112 KB
最終ジャッジ日時 2023-08-30 14:02:53
合計ジャッジ時間 9,343 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 417 ms
86,660 KB
testcase_01 AC 75 ms
71,420 KB
testcase_02 AC 76 ms
71,316 KB
testcase_03 AC 80 ms
75,452 KB
testcase_04 AC 76 ms
71,184 KB
testcase_05 AC 86 ms
76,820 KB
testcase_06 AC 84 ms
76,516 KB
testcase_07 AC 79 ms
75,876 KB
testcase_08 AC 107 ms
76,612 KB
testcase_09 WA -
testcase_10 AC 435 ms
87,024 KB
testcase_11 AC 377 ms
87,112 KB
testcase_12 AC 95 ms
77,072 KB
testcase_13 AC 98 ms
76,884 KB
testcase_14 AC 358 ms
86,376 KB
testcase_15 AC 74 ms
71,044 KB
testcase_16 WA -
testcase_17 AC 74 ms
71,408 KB
testcase_18 AC 421 ms
87,088 KB
testcase_19 AC 95 ms
76,736 KB
testcase_20 AC 360 ms
86,784 KB
testcase_21 AC 429 ms
87,028 KB
testcase_22 AC 388 ms
87,048 KB
testcase_23 WA -
testcase_24 AC 97 ms
76,732 KB
testcase_25 AC 97 ms
76,924 KB
testcase_26 AC 140 ms
76,888 KB
testcase_27 AC 159 ms
76,872 KB
testcase_28 AC 266 ms
86,400 KB
testcase_29 AC 145 ms
76,792 KB
testcase_30 AC 429 ms
86,832 KB
testcase_31 AC 381 ms
86,956 KB
testcase_32 WA -
testcase_33 AC 106 ms
76,724 KB
testcase_34 AC 106 ms
76,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
from sys import stdin
n, m, *a = map(int, stdin.read().split())
p = 10**9+7

divideset = set()
for i in range(1,int(math.floor(math.sqrt(m)))+2):
    if m % i == 0:
        divideset.add(i)
        divideset.add(m//i)

dividelist = list(divideset)
dividelist.sort()
dividedict = dict()
nd = len(dividelist)
for i in range(nd):
    dividedict[dividelist[i]] = i

for i in range(n):
    kari = math.gcd(a[i],m)
    a[i] = kari

dp = [[0 for i in range(nd)] for j in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for j in range(nd):
        kari = a[i] * dividelist[j]
        val = math.gcd(kari,m)
        dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % p
        dp[i+1][dividedict[val]] = (dp[i+1][dividedict[val]] + dp[i][j]) % p

ans = dp[n][nd-1]
print("{}".format(ans))
0