結果

問題 No.1973 Divisor Sequence
ユーザー ShirotsumeShirotsume
提出日時 2022-06-13 01:46:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,161 bytes
コンパイル時間 1,167 ms
コンパイル使用メモリ 81,552 KB
実行使用メモリ 486,552 KB
最終ジャッジ日時 2023-10-24 20:51:55
合計ジャッジ時間 11,785 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,512 KB
testcase_01 AC 45 ms
55,448 KB
testcase_02 AC 609 ms
277,916 KB
testcase_03 AC 100 ms
92,340 KB
testcase_04 AC 334 ms
191,436 KB
testcase_05 AC 295 ms
175,584 KB
testcase_06 AC 442 ms
239,836 KB
testcase_07 AC 122 ms
102,756 KB
testcase_08 AC 259 ms
161,704 KB
testcase_09 AC 297 ms
176,304 KB
testcase_10 AC 716 ms
330,216 KB
testcase_11 AC 98 ms
91,736 KB
testcase_12 AC 367 ms
206,920 KB
testcase_13 AC 242 ms
149,948 KB
testcase_14 AC 431 ms
226,512 KB
testcase_15 AC 384 ms
213,964 KB
testcase_16 AC 456 ms
244,808 KB
testcase_17 AC 621 ms
287,776 KB
testcase_18 AC 100 ms
83,376 KB
testcase_19 AC 757 ms
346,300 KB
testcase_20 AC 113 ms
98,140 KB
testcase_21 AC 593 ms
281,116 KB
testcase_22 AC 388 ms
214,900 KB
testcase_23 AC 732 ms
283,104 KB
testcase_24 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from functools import lru_cache
import sys
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
INF = 2 ** 63 - 1
mod = 10 ** 9 + 7
from math import gcd
def isprime(n):
    if n <= 2:
        return n == 2
    if n % 2 == 0:
        return False
    s = 0
    t = n - 1
    while t % 2 == 0:
        s += 1
        t //= 2
    
    for a in [2, 3, 5, 7, 11, 13, 17, 19, 23, 31, 37]:
        if a >= n:
            break
        x = pow(a, t, n)
        if x == 1 or x == n - 1:
            continue
        for _ in range(s):
            x = (x * x) % n
            if x == n - 1:
                break
        if x == n - 1:
            continue

        return False
    return True

def Pollad(N):
    if N % 2 == 0:
        return 2
    if isprime(N):
        return N
    def f(x):
        return (x * x + 1) % N
    step = 0

    while True:
        step += 1
        x = step
        y = f(x)
        while True:
            p = gcd(y - x + N, N)
            if p == 0 or p == N:
                break
            if p != 1:
                return p
            x = f(x)
            y = f(f(y))


def Primefact(N):
    if N == 1:
        return []
    q = []
    q.append(N)
    ret = []
    while q:
        now = q.pop()
        if now == 1:
            continue
        p = Pollad(now)
        if p == now:
            ret.append(p)
        else:
            q.append(p)
            q.append(now // p)

    return ret


n, m = mi()

D = Counter(Primefact(m))
@lru_cache(maxsize=None)
def solve(n, c):
    dp = [[0] * 40 for _ in range(n)]
    for i in range(c + 1):
        dp[0][i] = 1
    for i in range(n - 1):
        DP = [0] * 40
        DP[0] = dp[i][0]
        for j in range(39):
            DP[j + 1] += DP[j] + dp[i][j + 1]
            DP[j + 1] %= mod

        for j in range(40):
            if j > c:
                break
            dp[i + 1][j] += DP[c - j]
            dp[i + 1][j] %= mod
    return sum(dp[n - 1]) % mod


ans = 1
for v, c in D.items():
    ans *= solve(n, c)
    ans %= mod
print(ans)


            

0