結果

問題 No.1973 Divisor Sequence
ユーザー vwxyzvwxyz
提出日時 2023-11-21 04:36:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,515 ms / 2,000 ms
コード長 2,842 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 90,736 KB
最終ジャッジ日時 2023-11-21 04:37:13
合計ジャッジ時間 13,766 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
88,688 KB
testcase_01 AC 146 ms
88,688 KB
testcase_02 AC 761 ms
90,480 KB
testcase_03 AC 221 ms
90,352 KB
testcase_04 AC 562 ms
90,480 KB
testcase_05 AC 260 ms
90,224 KB
testcase_06 AC 572 ms
90,480 KB
testcase_07 AC 296 ms
90,608 KB
testcase_08 AC 360 ms
90,480 KB
testcase_09 AC 461 ms
90,480 KB
testcase_10 AC 586 ms
90,480 KB
testcase_11 AC 239 ms
90,352 KB
testcase_12 AC 459 ms
90,480 KB
testcase_13 AC 271 ms
90,352 KB
testcase_14 AC 448 ms
90,480 KB
testcase_15 AC 642 ms
90,480 KB
testcase_16 AC 669 ms
90,480 KB
testcase_17 AC 499 ms
90,608 KB
testcase_18 AC 211 ms
90,736 KB
testcase_19 AC 588 ms
90,736 KB
testcase_20 AC 274 ms
90,352 KB
testcase_21 AC 626 ms
90,480 KB
testcase_22 AC 582 ms
90,480 KB
testcase_23 AC 1,124 ms
90,224 KB
testcase_24 AC 1,515 ms
90,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
#sys.set_int_max_str_digits(10**9)

def Factorize(N):
    assert N>=1
    factors=defaultdict(int)
    for p in range(2,N):
        if p**2>N:
            break
        while N%p==0:
            factors[p]+=1
            N//=p
    if N!=1:
        factors[N]+=1
    return factors
class Cumsum:
    def __init__(self,lst,mod=0):
        self.N=len(lst)
        self.mod=mod
        self.cumsum=[0]*(self.N+1)
        self.cumsum[0]=0
        for i in range(1,self.N+1):
            self.cumsum[i]=self.cumsum[i-1]+lst[i-1]
            if self.mod:
                self.cumsum[i]%=self.mod

    def __getitem__(self,i):
        if type(i)==int:
            if 0<=i<self.N:
                a,b=i,i+1
            elif -self.N<=i<0:
                a,b=i+self.N,i+self.N+1
            else:
                raise IndexError('list index out of range')
        else:
            a,b=i.start,i.stop
            if a==None or a<-self.N:
                a=0
            elif self.N<=a:
                a=self.N
            elif a<0:
                a+=self.N
            if b==None or self.N<=b:
                b=self.N
            elif b<-self.N:
                b=0
            elif b<0:
                b+=self.N
        s=self.cumsum[b]-self.cumsum[a]
        if self.mod:
            s%=self.mod
        return s

    def __setitem__(self,i,x):
        if -self.N<=i<0:
            i+=self.N
        elif not 0<=i<self.N:
            raise IndexError('list index out of range')
        self.cumsum[i+1]=self.cumsum[i]+x
        if self.mod:
            self.cumsum[i+1]%=self.mod

    def __len__(self):
        return self.N

    def __str__(self):
        lst=[self.cumsum[i+1]-self.cumsum[i] for i in range(self.N)]
        if self.mod:
            for i in range(self.N):
                lst[i]%=self.mod
        return "["+", ".join(map(str,lst))+"]"

N,M=map(int,readline().split())
ans=1
mod=10**9+7
for p,e in Factorize(M).items():
    dp=Cumsum([1]+[0]*e,mod=mod)
    for i in range(N):
        dp=Cumsum([dp[:e+1-i] for i in range(e+1)],mod=mod)
    ans*=dp[:]
    ans%=mod
print(ans)
0