Problem:


Score : 400 points

Problem Statement

You are given positive integers N and M.

How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7.

Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

1 \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.

Sample Input 1

2 6

Sample Output 1

4

Four sequences satisfy the condition: \{a_1, a_2\} = \{1, 6\}, \{2, 3\}, \{3, 2\} and \{6, 1\}.

Sample Input 2

3 12

Sample Output 2

18

Sample Input 3

100000 1000000000

Sample Output 3

957870001



Sample input:
2 6


Sample output:
4

Submission status: Accepted

Solution code:
from collections import Counter
from math import sqrt

#f_listとf_r_listの要素数は状況に応じて変えよう

MOD = (10 ** 9) + 7

list_size = 3 * (10 ** 5)

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

def power(n, x):
	if x == 1:
		return n
	elif x % 2 == 0:
		return power(int((n * n) % MOD), int(x / 2))
	else:
		return int((n * power(n, x - 1)) % MOD)

f_r_list[-1] = power(f_list[-1], MOD - 2)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

#prime = [2]

def is_prime(i):
	if i == 1:
		return False
	#global prime
	for j in range(2, int(sqrt(i)) + 1):
		if i % j == 0:
			return False
	return True

n, m = map(int, input().split())
prime_factor = Counter()

for i in range(2, int(sqrt(m)) + 1):
	if m % i == 0:
		prime_factor[i] += 1
		m = m // i
		while m % i == 0:
			prime_factor[i] += 1
			m = m // i
	if is_prime(m):
		prime_factor[m] += 1
		break

ans = 1
for i in prime_factor.values():
	ans *= comb(n + i - 1, i)
	ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
N,M = map(int, raw_input().split())
MOD = 10**9+7

F = [0]*100100
F[0] = 1
for i in range(1,100100):
  F[i] = i*F[i-1]%MOD

ans = 1
d = 2
while M>1:
  c = 0
  while M%d==0:
    M /= d
    c += 1
  if c>0:
    ans *= F[N+c-1]
    ans %= MOD
    ans *= pow(F[N-1], MOD-2, MOD)
    ans %= MOD
    ans *= pow(F[c], MOD-2, MOD)
    ans %= MOD
  d += 1
  if d*d>M:
    d = M

print ans

Submission status: Accepted

Solution code:
from sys import stdin 
hi = 10**5 + 105 
mod = 10**9 + 7 
fa = [1] * hi 
for i in xrange(1,hi):
    fa[i] = (i * fa[i-1])%mod 
def ncr(n,r):
    num = fa[n]
    den = (fa[r] * fa[n-r])%mod 
    den = pow(den, mod-2, mod)
    return (num * den)%mod 

n,m = map(int,stdin.readline().split())
di = {} 
x = 2 
ans = 1 
while True:
    if x * x > m:
        break 
    if m%x==0:
        cnt = 0 
        while m%x==0:
            m/=x 
            cnt+= 1 
        ans = (ans * ncr(n-1+cnt,cnt))%mod 
    x+=1 
if m!=1:
    ans = (ans * n)%mod 
print ans

Submission status: Runtime Error

Solution code:
class Factorials:
    def __init__(self, n=10**6, mod=10**9 + 7):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        self.fac = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            self.fac.append(num)

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        self.rec = [1 for i in range(n+1)]
        self.rec[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            self.rec[i] = num

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod
    
    # perm(n, r) ≡ nPr
    def perm(self, n, r):
        return self.fac[n] * self.rec[n-r] % self.mod

    # fact(n) ≡ n!
    def fact(self, n):
        return self.fac[n]

def main():
    mod = 10**9 + 7
    n, m = map(int, input().split())

    factors = []
    for i in range(2, m+1):
        if i * i > m:
            if m > 1:
                factors.append(1)
            break

        if m % i == 0:
            num = 1
            m //= i
            while m % i == 0:
                num += 1
                m //= i
            factors.append(num)

    fct = Factorials(n=n+max(factors), mod=mod)

    ans = 1
    for i in factors:
        ans *= fct.comb(n+i-1, i)
        ans %= mod

    print(ans)

main()

Submission status: Runtime Error

Solution code:
from collections import defaultdict
N,M = map(int,input().split())
d = defaultdict(int)
for i in range(2, floor(sqrt(M))+1):
    while M % i == 0:
        d[i] += 1
        M //= i
if M != 1:
    d[M] += 1
def comb(n,k):
    if k == 0:
        return 1
    return comb(n-1,k-1) * n // k
ans = 1
for e in d.values():
    ans *= comb(N+e-1, e)
print(ans % (10**9+7))

Submission status: Runtime Error

Solution code:
def factorize(n):
    factor = []
    if n % 2 == 0:
        f = [2, 1]
        n //= 2
        while n % 2 == 0:
            n //= 2
            f[1] += 1
        factor.append(f)
    k = 3
    while k * k <= n:
        if n % k == 0:
            f = [k, 1]
            n //= k
            while n % k == 0:
                n //= k
                f[1] += 1
            factor.append(f)
        k += 2
    if n != 1:
        factor.append([n, 1])
    return factor

def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod # 除数が正なら正になる
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod # 除数が正なら正になる

n, m = map(int, input().split())
mod = 10 ** 9 + 7
f = factorize(m)
max_k = max(i for _, i in f)
fac, inv = factorial(n + max_k - 1, mod)

ans = 1
for _, k in f:
    ans = ans * fac[n + k - 1] % mod * inv[n - 1] % mod * inv[k] % mod
print(ans)

Submission status: Runtime Error

Solution code:
import math

N, M = map(int, input().split())
visited = set()

limit = math.ceil(math.sqrt(M))
A = []
for i in range(2, limit+1):
  if i in visited:
    continue
  j = i
  while j <= limit:
    visited.add(j)
    j += i
  del j
  k = 0
  while M % i == 0:
    M = M // i
    k += 1
  A.append(k)
if M > 1:
  A.append(1)

  
MOD = 10**9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

K = max(A) + N - 1
for i in range(2, K + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

# ②事前計算した項を掛け合わせ
def cmb(n, r, MOD):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD
  
ans = 1  
for a in A:
  ans *= cmb(a + N-1, N-1, MOD)
  ans %= MOD
  
print(ans)
#print(A)

Submission status: Runtime Error

Solution code:
mod=10**9+7
dic={}
def ADD(x):
	if x in dic:
		dic[x]+=1
	else:
		dic[x]=1
n,m=map(int,input().split())
for i in range(2,int(m**0.5+2)):
	while m%i==0:
		ADD(i)
		m//=i
if m>1:
	ADD(m)
dic=tuple(dic.values())
ans=1
fac=[1]
for i in range(n+max(dic)+2):
	fac.append(fac[-1]*(i+1)%mod)
def c(a,b):
	r=pow(fac[b]*fac[a-b]%mod,mod-2,mod)
	return fac[a]*r%mod
for x in dic:
	ans*=c(x+n-1,x)
	ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
mod=10**9+7
dic={}
def ADD(x):
	if x in dic:
		dic[x]+=1
	else:
		dic[x]=1
n,m=map(int,input().split())
for i in range(2,int(m**0.5+2)):
	while m%i==0:
		ADD(i)
		m//=i
if m>1:
	ADD(m)
dic=tuple(dic.values())
ans=1
fac=[1]
for i in range(2*n+2):
	fac.append(fac[-1]*(i+1)%mod)
def c(a,b):
	r=pow(fac[b]*fac[a-b]%mod,mod-2,mod)
	return fac[a]*r%mod
for x in dic:
	ans*=c(x+n-1,x)
	ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter

n, m = list(map(int, input().split()))
MOD = pow(10, 9) + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def make_fact_list(n, MOD):
    # make factorial list from 0 to n
    fact = [0] * (n+1)
    inv = [0] * (n+1)
    factinv = [0] * (n+1)

    fact[0]=fact[1]=1
    inv[1]=1
    factinv[0]=factinv[1]=1

    for i in range(2,n+1):
        fact[i] = fact[i-1] * i % MOD
        inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
        factinv[i] = factinv[i-1] * inv[i] % MOD
    
    return fact, factinv

def cbn(n, k, MOD, fact = [], factinv = []):
    if len(fact) == 0 and len(factinv) == 0:
        fact, factinv = make_fact_list(n, MOD)
    return fact[n] * factinv[n-k] * factinv[k] % MOD


d = Counter(prime_factorize(m)).most_common()

l = d[0][1] + n 

fact, factinv = make_fact_list(l, MOD)

a = 1

for k, v in d:
    a *= cbn(v + n - 1, v, MOD, fact = fact, factinv = factinv) % MOD

print(a % MOD)

Submission status: Runtime Error

Solution code:
n = int(input())
m = int(input())
a = list(map(int,input().split()))
M = 10000

dp = [[0]*(m+1) for i in range(n+1)]

for i in range(n+1):
    dp[i][0] = 1
    
for i in range(n):
    for j  in range(1,m+1):
        if j - 1 - a[i] >= 0:
            dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j] - dp[i][j - 1 - a[i]] ) % M
        else:
            dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j]) % M
            
print(dp)

Submission status: Runtime Error

Solution code:
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
N,M = map(int,input().split())
A = [1 for _ in range(N+100)]
for i in range(2,N+100):
    A[i] = (A[i-1]*i)%p
B = [1 for _ in range(N+100)]
B[N+100-1] = pow(A[N+100-1],p-2)
for i in range(N+100-2,1,-1):
    B[i] = (B[i+1]*(i+1))%p
P = [1 for _ in range(10**5)]
P[0]=0
P[1]=0
for i in range(2,int((10**5)**0.5)+1):
    for j in range(i*i,10**5,i):
        P[j] = 0
Q = []
for i in range(2,10**5):
    if P[i]==1:
        Q.append(i)

C = {q:0 for q in Q}
for q in Q:
    if M%q==0:
        while M%q==0:
            M = M//q
            C[q] += 1
if M>1:
    C[M] = 1
Q.append(M)
prod = 1
for q in Q:
    k = C[q]
    a = A[k+N-1]
    a = (a*B[N-1])%p
    a = (a*B[k])%p
    prod = (prod*a)%p
print(prod)

Submission status: Runtime Error

Solution code:
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
A = [1 for _ in range(N+100)]
for i in range(2,N+100):
    A[i] = (A[i-1]*i)%p
B = [1 for _ in range(N+100)]
B[N+100-1] = pow(A[N+100-1],p-2)
for i in range(N+100-2,1,-1):
    B[i] = (B[i+1]*(i+1))%p
P = [1 for _ in range(10**5)]
P[0]=0
P[1]=0
for i in range(2,int((10**5)**0.5)+1):
    for j in range(i*i,10**5,i):
        P[j] = 0
Q = []
for i in range(2,10**5):
    if P[i]==1:
        Q.append(i)
N,M = map(int,input().split())
C = {q:0 for q in Q}
for q in Q:
    if M%q==0:
        while M%q==0:
            M = M//q
            C[q] += 1
if M>1:
    C[M] = 1
prod = 1
for q in Q:
    k = C[q]
    a = A[k+N-1]
    a = (a*B[N-1])%p
    a = (a*B[k])%p
    prod = (prod*a)%p
print(prod)

Submission status: Runtime Error

Solution code:
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
A = [1 for _ in range(N+100)]
for i in range(2,N+100):
    A[i] = (A[i-1]*i)%p
B = [1 for _ in range(N+100)]
B[N+100-1] = pow(A[N+100-1],p-2)
for i in range(N+100-2,1,-1):
    B[i] = (B[i+1]*(i+1))%p
P = [1 for _ in range(10**5)]
P[0]=0
P[1]=0
for i in range(2,int((10**5)**0.5)+1):
    for j in range(i*i,10**5,i):
        P[j] = 0
Q = []
for i in range(2,10**5):
    if P[i]==1:
        Q.append(i)
N,M = map(int,input().split())
C = {q:0 for q in Q}
for q in Q:
    if M%q==0:
        while M%q==0:
            M = M//q
            C[q] += 1
prod = 1
for q in Q:
    k = C[q]
    a = A[k+N-1]
    a = (a*B[N-1])%p
    a = (a*B[k])%p
    prod = (prod*a)%p
print(prod)

Submission status: Runtime Error

Solution code:
from math import factorial
n,m=map(int,input().split())
def p_fact(n):
  m=n
  i=2
  a=[]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a
def comp(s):
  n=len(s)
  cnt=1
  flag=s[0]
  a=[]
  for i in range(1,n):
    if flag==s[i]:cnt+=1
    else:
      flag=s[i]
      a+=[cnt]
      cnt=1
  a+=[cnt]
  return a
class mod_comb_k():
  def __init__(self, MAX_N = 10**6, mod = 10**9+7):
    self.fact = [1]
    self.fact_inv = [0] * (MAX_N + 4)
    self.mod = mod
    if MAX_N > mod:print('MAX_N > mod !')
    for i in range(MAX_N + 3):
      self.fact.append(self.fact[-1] * (i + 1) % self.mod)
    self.fact_inv[-1] = pow(self.fact[-1], self.mod - 2, self.mod)
    for i in range(MAX_N + 2, -1, -1):
      self.fact_inv[i] = self.fact_inv[i + 1] * (i + 1) % self.mod
  def comb(self, n, k):
    if n < k:
      #print('n < k !')
      return 0
    else:return self.fact[n] * self.fact_inv[k] % self.mod * self.fact_inv[n - k] % self.mod
mod=10**9+7
c=mod_comb_k()
a=comp(p_fact(m))
ans=1
for i in a:
  ans*=c.comb(n-1+i,i)
print(ans%mod)

Submission status: Runtime Error

Solution code:
from scipy.misc import comb

def solve(n,m):
    maxdiv = int(m**0.5)
    l = []
    tmp = 2
    num = 0
    while tmp <= maxdiv:
        if m % tmp == 0:
            m /= tmp
            num += 1
        else:
            tmp += 1
            if num != 0:
                l.append(num)
                num = 0
    if m != 1:
        l.append(1)
    res = 1
    for div in l:
        tmp = comb(n+div-1,div,exact=True)%(10**9+7)
        res = res * tmp % (10**9+7)
    return int(res)
        

if __name__ == '__main__':
    n,m = map(int,input().split())
    print(solve(n,m))

Submission status: Runtime Error

Solution code:
from scipy.special import comb

def solve(n,m):
    maxdiv = int(m**0.5)
    l = []
    tmp = 2
    num = 0
    while tmp <= maxdiv:
        if m % tmp == 0:
            m /= tmp
            num += 1
        else:
            tmp += 1
            if num != 0:
                l.append(num)
                num = 0
    if m != 1:
        l.append(1)
    res = 1
    for div in l:
        tmp = comb(n+div-1,div,exact=True)%(10**9+7)
        res = res * tmp % (10**9+7)
    return int(res)
        

if __name__ == '__main__':
    n,m = map(int,input().split())
    print(solve(n,m))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
MOD=10**9+7
 
def cmb(n, r, p):
  numerator = 1
  for i in range(n-r+1, n+1):
    numerator = numerator * i % p
  denominator = 1
  for j in range(1, r+1):
    denominator = denominator * j % p
  denominator = pow(denominator, p-2, p)
  return (numerator * denominator)%p
 
def factorization(n):
  l = []
  t = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if t%i==0:
      cnt=0
      while t%i==0:
        cnt+=1
        t //= i
      l.append([i, cnt])
  if t!=1:
    l.append([temp, 1])
  if l==[]:
    l.append([n, 1])
  return l
 
ans=1
F=factorization(M)
for i in range(len(F)):
  f=F[i][1]
  ans*=cmb(f+N-1,f,MOD)
  ans%=MOD

if M==1:
  print(1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
mod = 10**9+7

pos = {}
neg = {}
n = 1
for i in range(1, 500000):
    n *= i
    n %= mod
    pos[i] = n
    neg[i] = pow(n, mod-2, mod)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
primes = prime_factorize(M)
c = Counter(primes)
primes = list(set(primes))
leng = len(primes)
ans = 1
for i in range(leng):
    p = primes[i]
    n = c[p]
    ans *= pos[N+n-1]*neg[n]*neg[N-1]
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
mod = 10**9+7

pos = {}
neg = {}
n = 1
for i in range(1, 200000):
    n *= i
    n %= mod
    pos[i] = n
    neg[i] = pow(n, mod-2, mod)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
primes = prime_factorize(M)
c = Counter(primes)
primes = list(set(primes))
leng = len(primes)
ans = 1
for i in range(leng):
    p = primes[i]
    n = c[p]
    ans *= pos[N+n-1]*neg[n]*neg[N-1]
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
#素因数分解
def soinsu_bunkai(m):
    pf={}

    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:
        pf[m]=1
    return pf

# 組み合わせの総数 p=10**9+7 で割ったあまりを求める Satoooh Blog 2020/02/27 4分 
"""n<10**7 , p は素数"""
def cmb(n, r, p):

    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p



# 初期入力
from collections import Counter
import sys
input = sys.stdin.readline  #文字列では使わない
mod =10**9 +7
p =mod
N,M = map(int, input().split())
a =soinsu_bunkai(M)
ans =1

n = 10 ** 5+1  # n は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

#mod p における n の逆元の計算
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in a.values():
    x =cmb(N +i -1,i,mod)
    ans *=x
print(ans %mod)

Submission status: Runtime Error

Solution code:
import collections

def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

def nCr(n,r):
  return (FAC[n]*INV[n-r]*INV[r])%MOD

n,m = map(int,input().split())

MOD = 10**9 + 7
FAC = [1]
INV = [1]
N = 2*n
for i in range(1,N+1):
  FAC.append((FAC[i-1]*i) % MOD)
  INV.append(pow(FAC[-1],MOD-2,MOD))

c = collections.Counter(prime_factorize(m))
#print(c)
ans = 1
for k,v in c.items():
  ans *= nCr(v+n-1,v)
  ans %= MOD
print(ans)

Submission status: Runtime Error

Solution code:
def main():
  N, M = map(int, input().split())

   def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])
        if temp != 1:
            arr.append([temp, 1])

        if arr == [] and n != 1:
            arr.append([n, 1])

        return arr

    mod = 10**9 + 7

    def cmb(n, r, mod):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]
    for i in range(2, N+100 + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    primes = factorization(M)
    # 何箇所に分けるか（cnt以下）,その中でどう分けるか（しきりをどこにおくか（振り分けられないものが出ると選べれないのとおなじになるので、cnt - 選んだ数））

    ans = 1

    for p, cnt in primes:
        tmp = cmb(N+cnt-1, N-1, mod)
        ans *= tmp
        ans %= mod

    print(ans)


main()

Submission status: Runtime Error

Solution code:
def main()
  N, M = map(int, input().split())

   def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])
        if temp != 1:
            arr.append([temp, 1])

        if arr == [] and n != 1:
            arr.append([n, 1])

        return arr

    mod = 10**9 + 7

    def cmb(n, r, mod):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]
    for i in range(2, N+100 + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    primes = factorization(M)
    # 何箇所に分けるか（cnt以下）,その中でどう分けるか（しきりをどこにおくか（振り分けられないものが出ると選べれないのとおなじになるので、cnt - 選んだ数））

    ans = 1

    for p, cnt in primes:
        tmp = cmb(N+cnt-1, N-1, mod)
        ans *= tmp
        ans %= mod

    print(ans)


main()

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])

    if arr == [] and n != 1:
        arr.append([n, 1])

    return arr


mod = 10**9 + 7


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N*2 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


primes = factorization(M)
# 何箇所に分けるか（cnt以下）,その中でどう分けるか（しきりをどこにおくか（振り分けられないものが出ると選べれないのとおなじになるので、cnt - 選んだ数））

ans = 1

for p, cnt in primes:
    tmp = cmb(N+cnt-1, N-1, mod)
    ans *= tmp
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])

    if arr == [] and n != 1:
        arr.append([n, 1])

    return arr


mod = 10**9 + 7


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N + int(math.log(M)+1) + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


primes = factorization(M)
# 何箇所に分けるか（cnt以下）,その中でどう分けるか（しきりをどこにおくか（振り分けられないものが出ると選べれないのとおなじになるので、cnt - 選んだ数））
if N == 1:
    print(1)
    exit(0)
ans = 1

for p, cnt in primes:
    tmp = cmb(N+cnt-1, N-1, mod)
    ans *= tmp
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


mod = 10**9 + 7


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


primes = factorization(M)
# 何箇所に分けるか（cnt以下）,その中でどう分けるか（しきりをどこにおくか（振り分けられないものが出ると選べれないのとおなじになるので、cnt - 選んだ数））

if N == 1:
    print(1)
ans = 1
for p, cnt in primes:
    tmp = 0
    for i in range(1, min(cnt, N)+1):
        tmp += cmb(N, i, mod) * cmb(cnt-1, i-1, mod)
        #print(tmp, p, cnt, i)
        tmp %= mod
    ans *= tmp
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    return(arr)


mod = 10**9 + 7


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


primes = factorization(M)
# 何箇所に分けるか（cnt以下）,その中でどう分けるか（しきりをどこにおくか（振り分けられないものが出ると選べれないのとおなじになるので、cnt - 選んだ数））

ans = 1
for p, cnt in primes:
    tmp = 0
    for i in range(1, min(cnt, N)+1):
        tmp += cmb(N, i, mod) * cmb(cnt-i + i-1, i-1, mod)
        #print(tmp, p, cnt, i)
        tmp %= mod
    ans *= tmp
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
N,M = list(map(int,input().split()))

MAXN = (10**5)+10
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

def prime(X):
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    return pf

pf = prime(M)
powers = list(pf.values())

out = 1
for power in powers:
    out = out*nCr(power+N-1,power)%p

print(out)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
MOD = 10**9+7

def factorize(N):
    res = []
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res.append(num)
    if N>1: res.append(1)
    return res

res = factorize(M)

n = max(res) + N 

fac = [1]*n
inv = [1]*n
finv = [1]*n

for i in range(2, n):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

ans = 1
for m in res:
    a = fac[m+N-1] * (finv[m] * finv[N-1] % MOD) % MOD
    ans = ans*a%MOD

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
MOD = 10**9+7

def factorize(N):
    res = {}
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
    if N>1: res[N] = 1
    return res

res = factorize(M)

n = max(res.values()) + N + 1

fac = [1]*n
inv = [1]*n
finv = [1]*n

for i in range(2, n):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

ans = 1
for m in res.values():
    a = fac[m+N-1] * (finv[m] * finv[N-1] % MOD) % MOD
    ans = ans*a%MOD

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
MOD = 10**9+7

def factorize(N):
    res = {}
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
    if N>1: res[N] = 1
    return res

res = factorize(M)

n = max(res.values()) + N + 10

fac = [1]*n
inv = [1]*n
finv = [1]*n

for i in range(2, n):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

ans = 1
for m in res.values():
    a = fac[m+N-1] * (finv[m] * finv[N-1] % MOD) % MOD
    ans = ans*a%MOD

print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = map(int, input().split())
d = factor(m)

def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr
M = 10**9+7 # 出力の制限
N = max(d.values())+10+n # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M

if m!=1:
    ans = 1
    for v in d.values():
        ans *= cmb(v+n-1, n-1, M)
        ans %= M
else:
    ans = 1
print(ans%M)

Submission status: Runtime Error

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = map(int, input().split())
d = factor(m)

def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr
M = 10**9+7 # 出力の制限
N = max(d.values())+10+n # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M

ans = 1
for v in d.values():
    ans *= cmb(v+n-1, n-1, M)
    ans %= M
print(ans)