結果

問題 No.1973 Divisor Sequence
ユーザー ShirotsumeShirotsume
提出日時 2022-06-13 01:48:53
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,219 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 81,712 KB
実行使用メモリ 485,604 KB
最終ジャッジ日時 2023-10-24 20:53:57
合計ジャッジ時間 11,678 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,576 KB
testcase_01 AC 43 ms
55,576 KB
testcase_02 AC 578 ms
277,964 KB
testcase_03 AC 103 ms
92,392 KB
testcase_04 AC 309 ms
191,488 KB
testcase_05 AC 277 ms
175,640 KB
testcase_06 AC 404 ms
239,884 KB
testcase_07 AC 119 ms
102,808 KB
testcase_08 AC 245 ms
161,756 KB
testcase_09 AC 276 ms
176,356 KB
testcase_10 AC 661 ms
330,284 KB
testcase_11 AC 99 ms
91,784 KB
testcase_12 AC 340 ms
206,968 KB
testcase_13 AC 231 ms
150,000 KB
testcase_14 AC 401 ms
226,568 KB
testcase_15 AC 356 ms
214,020 KB
testcase_16 AC 417 ms
244,860 KB
testcase_17 AC 568 ms
287,844 KB
testcase_18 AC 95 ms
83,420 KB
testcase_19 AC 710 ms
346,104 KB
testcase_20 AC 109 ms
98,188 KB
testcase_21 AC 553 ms
281,164 KB
testcase_22 AC 357 ms
214,952 KB
testcase_23 AC 695 ms
283,156 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))
C = [0] * 100
def solve(n, c):
    if C[c] > 0:
        return C[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
    C[c] = sum(dp[n - 1]) % mod
    return sum(dp[n - 1]) % mod


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


            

0