結果

問題 No.1973 Divisor Sequence
ユーザー ああいいああいい
提出日時 2022-06-12 07:45:16
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 838 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 88,352 KB
最終ジャッジ日時 2023-10-24 00:32:28
合計ジャッジ時間 5,003 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
57,836 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 70 ms
68,440 KB
testcase_03 AC 51 ms
60,168 KB
testcase_04 AC 66 ms
66,360 KB
testcase_05 AC 55 ms
59,540 KB
testcase_06 AC 51 ms
62,152 KB
testcase_07 AC 54 ms
59,972 KB
testcase_08 AC 58 ms
62,152 KB
testcase_09 AC 65 ms
66,348 KB
testcase_10 AC 96 ms
75,944 KB
testcase_11 AC 65 ms
68,420 KB
testcase_12 AC 59 ms
62,188 KB
testcase_13 AC 53 ms
62,192 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
P = 10 ** 9 + 7

div = []
i = 1
while i * i <= M:
    if M % i == 0:
        div.append(i)
        if i != M // i:
            div.append(M // i)
    i += 1
n = len(div)
s = set(div)
R = [[0] * n for _ in range(n)]
for i in range(n):
    p = div[i]
    for j in range(n):
        q = div[j]
        if p * q in s:
            R[j][i] += 1
def seki(x,y):
    l = [[0] * n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                l[i][j] += x[i][k] * y[k][j]
            l[i][j] %= P
    return l
e = [[0] * n for _ in range(n)]
for i in range(n):
    e[i][i] = 1
u = N - 1
while u:
    if u & 1:
        e = seki(e,R)
    R = seki(R,R)
    u >>= 1
ans = 0
for i in range(n):
    for j in range(n):
        ans += e[i][j]
        ans %= P
print(ans)
0