結果

問題 No.1973 Divisor Sequence
ユーザー ShirotsumeShirotsume
提出日時 2022-06-11 00:14:20
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,105 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 81,680 KB
実行使用メモリ 491,940 KB
最終ジャッジ日時 2023-10-21 06:24:01
合計ジャッジ時間 24,502 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
60,072 KB
testcase_01 AC 42 ms
55,724 KB
testcase_02 TLE -
testcase_03 AC 142 ms
109,000 KB
testcase_04 AC 1,175 ms
309,548 KB
testcase_05 AC 286 ms
175,612 KB
testcase_06 AC 1,199 ms
373,488 KB
testcase_07 AC 251 ms
156,420 KB
testcase_08 AC 699 ms
323,320 KB
testcase_09 AC 1,043 ms
279,064 KB
testcase_10 AC 1,290 ms
331,448 KB
testcase_11 AC 209 ms
139,212 KB
testcase_12 AC 1,014 ms
340,608 KB
testcase_13 AC 324 ms
187,024 KB
testcase_14 AC 666 ms
280,928 KB
testcase_15 AC 1,688 ms
355,316 KB
testcase_16 AC 1,639 ms
417,252 KB
testcase_17 AC 1,092 ms
288,400 KB
testcase_18 AC 122 ms
93,424 KB
testcase_19 AC 1,409 ms
356,612 KB
testcase_20 AC 269 ms
164,780 KB
testcase_21 AC 1,554 ms
459,388 KB
testcase_22 AC 1,389 ms
356,904 KB
testcase_23 AC 730 ms
283,144 KB
testcase_24 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
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))

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