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: Wrong Answer

Solution code:
import math
from collections import defaultdict
N, M = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def get_all_prime_numbers(N):
    values = list(range(1, N + 1))
    flags = [1] * N
    flags[0] = 0  # delete 1
    for i in range(N):
        if flags[i] == 0:
            continue

        prime = values[i]
        for mult in range(2, N // prime + 1):
            cand = mult * prime
            if flags[cand - 1] == 1:
                flags[cand - 1] = 0

    prime_numbers = []
    for i in range(N):
        if flags[i] == 1:
            prime_numbers.append(values[i])
    return prime_numbers

def prime_factorization(N):  # O(N ** 0.5)
    prime_count_dict = defaultdict(int)
    tmp = N
    # N の素因数はたかだか N^{1/2}以下なので実はかなり早く取れるはず
    for n in get_all_prime_numbers(int(N ** 0.5) + 1):
        while True:
            if tmp % n == 0:
                tmp = tmp / n
                prime_count_dict[n] += 1
            else:
                break
    return prime_count_dict

def combination(a, b):  # pick only b elements from a elements
    b_ = min([b, a - b])
    ans = 1
    for i in range(b_):
        ans *= a - i
    return ans // math.factorial(b_)
    # this may result in multiplying too big numbers..
    # return int(math.factorial(a) / (math.factorial(b) * math.factorial(a - b)))

result = prime_factorization(M)

ans = 1
for v in result.values():
    ans *= combination(v + N - 1, N - 1)
    ans %= MOD
print(int(ans))

Submission status: Wrong Answer

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

def get_all_prime_numbers(N):
    values = list(range(1, N + 1))
    flags = [1] * N
    flags[0] = 0  # delete 1
    for i in range(N):
        if flags[i] == 0:
            continue

        prime = values[i]
        for mult in range(2, N // prime + 1):
            cand = mult * prime
            if flags[cand - 1] == 1:
                flags[cand - 1] = 0

    prime_numbers = []
    for i in range(N):
        if flags[i] == 1:
            prime_numbers.append(values[i])
    return prime_numbers

def prime_factorization(N):  # O(N ** 0.5)
    prime_count_dict = defaultdict(int)
    tmp = N
    # N の素因数はたかだか N^{1/2}以下なので実はかなり早く取れるはず
    for n in get_all_prime_numbers(int(N ** 0.5) + 1):
        while True:
            if tmp % n == 0:
                tmp = tmp / n
                prime_count_dict[n] += 1
            else:
                break
    return prime_count_dict


def combination(a, b):  # pick only b elements from a elements
    import math
    return int(math.factorial(a) / (math.factorial(b) * math.factorial(a - b)))

result = prime_factorization(M)
print(result)

ans = 1
for v in result.values():
    ans *= combination(v + N - 1, N - 1)
    ans = ans % (1e9 + 7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

def factor(n):
    r = []
    tmp = n
    for i in range(2, int(math.sqrt(n)) + 1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            r.append((i, cnt))
    if tmp != 1:
        r.append((tmp, 1))
    if not r:
        r.append((n, 1))
    return r

class nCrMod():
    def __init__(self, mod):
        self.mod = mod
        self.fac = [1, 1]
        self.finv = [1, 1]
        self.inv = [0, 1]

    def prep(self, n):
        mod = self.mod
        f, fi = self.fac[-1], self.finv[-1]
        for i in range(len(self.fac), n + 1):
            fn = f * i % mod
            v = -self.inv[mod % i] * (mod // i) % mod
            fin = fi * v % mod
            f, fi = fn, fin
            self.fac.append(f)
            self.finv.append(fi)
            self.inv.append(v)

    def __call__(self, n, r):
        if len(self.fac) <= n:
            self.prep(n)
        return self.fac[n] * self.finv[r] * self.finv[n - r] % self.mod

def main():
    N, M = map(int, input().split())
    mod = 10**9 + 7
    nCr = nCrMod(mod)
    f = factor(M)
    r = 1
    for p, q in f:
        r = r * nCr(N + q - 1, q) % mod
    return r

print(main())

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
mod=10**9+7
arr=[]
temp=M
for i in range(2,int(M**(1/2))+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([M,1])
def comb(n,k):
  return (int(math.factorial(n)))/((int(math.factorial(k)))*(int(math.factorial(n-k))))
ans=1
for i in range(len(arr)):
  ans*=int(comb(arr[i][1]+N-1,arr[i][1]))%mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
mod=10**9+7
arr=[]
temp=M
for i in range(2,int(M**(1/2))+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([M,1])
def comb(n,k):
  return (int(math.factorial(n)))/((int(math.factorial(k)))*(int(math.factorial(n-k))))
ans=1
for i in range(len(arr)):
  ans*=int(comb(arr[i][1]+N-1,arr[i][1]))
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import math

# 素因数分解
def prime_factorization(n):
    # s * s <= n
    s = math.floor(math.sqrt(n)) # 平方根を小数点切り捨て
    ans = [] # [素数, 指数]のリスト

    # 2からsまでの素因数を求める
    for i in [2] + list(range(3, s + 1, 2)):
        if n < i:
            break
        if n % i == 0:
            r = 0 # 指数カウンタクリア
            while n % i == 0:
                r += 1
                n //= i
            ans.append([i, r])

    # 残った素数を追加
    if n >= s:
        ans.append([n, 1])

    return(ans)

def binomial_p(n, k, p):
    '''
    Input: integers n, k such that n >= k >= 0, prime number p
    Output: n choose k mod p
    '''
    k = min(k, n-k)

    if k == 0:
        retval = 1
    elif k == 1:
        retval = n
    else:
        numer = n  # n * (n - 1) * ... * (n - k + 1)
        inv = [0, 1]    # inv[i] : inverse of i mod p
        inv_denom = 1 # factorial of inverse of k mod p = 1^(-1) * 2^(-1) * ... * k^(-1) mod p
        for i in range(2, k + 1):
            numer = numer * (n - i + 1) % p
            inv.append(( inv[p % i] * (p - p//i) ) % p ) # inverse of i
            inv_denom = inv_denom * inv[-1] % p
        retval = numer * inv_denom % p

    return retval

###########################

N, M = [int(x) for x in input().split()]
q = 10 ** 9 + 7

pfact = prime_factorization(M)
ans = 1
for pr in pfact:
    ans = ans * binomial_p(N - 1 + pr[1], pr[1], q) % q

print(ans)

Submission status: Wrong Answer

Solution code:
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

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
MOD = 10**9+7
for i in range(2, 2*10**5):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)

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


N, M = map(int, input().split())
n = N - 1
fac_m = factorization(M)
ans = 1
for _, m in fac_m:
  ans *= memo_comb(m+n, n)
  ans %= MOD

print(ans)

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
def prime(n,p):
    iteral = 0
    while n%p == 0:
        n //= p
        iteral += 1
    return iteral,n
def modpow(a,n):#二乗
    if n==0:
        return 1
    elif n==1:
        return a%mod
    elif n%2==0:
        return (modpow(a,n/2)**2)%mod
    else:
        return (a*modpow(a,n-1))%mod
def modfact(l,r):#階乗
    fact=1
    for i in range(l-r+1):
        fact=fact*(r+i)%mod
    return fact
def comb(n,x):#組み合わせ
    S=modfact(n,n-x+1)
    fact=modfact(x,1)
    T=modpow(fact,mod-2)
    return S*T%mod
def main():
    N,M = map(int,input().split())
    b = []
    for i in range(2,int(M**0.5)+10):
        num,M = prime(M,i)
        if num != 0:
            b.append(num)
    if not b:
        b = [1]
    ans = 1
    for num in b:
        ans *= comb(num+N-1,num)
        ans %= mod
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
def prime(n,p):
    iteral = 0
    while n%p == 0:
        n //= p
        iteral += 1
    return iteral,n
def modpow(a,n):#二乗
    if n==0:
        return 1
    elif n==1:
        return a%mod
    elif n%2==0:
        return (modpow(a,n/2)**2)%mod
    else:
        return (a*modpow(a,n-1))%mod
def modfact(l,r):#階乗
    fact=1
    for i in range(l-r+1):
        fact=fact*(r+i)%mod
    return fact
def comb(n,x):#組み合わせ
    S=modfact(n,n-x+1)
    fact=modfact(x,1)
    T=modpow(fact,mod-2)
    return S*T%mod
def main():
    N,M = map(int,input().split())
    b = []
    for i in range(2,int(M**0.5)+1):
        if M%i==0:
            num,M = prime(M,i)
            b.append(num)
        else:
            continue
    ans = 1
    for num in b:
        ans *= comb(num+N-1,num)
        ans %= mod
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
P=10**9+7
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
a=factorization(M)
ans=1
for x in a:
    c=1
    for i in range(x[1]):
        c*=(N+x[1]-i-1)
    for i in range(x[1]):
        c//=(i+1)
    ans*=c
    ans=ans%P
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,M=map(int,list(input().split(" ")))
mod=10**9+7
def factor(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

fac=np.array(factor(M))
ans=1
for i in range(len(fac)):
    ans*=cmb(N+fac[i][1]-1,N-1)
print(ans%mod)

Submission status: Wrong Answer

Solution code:
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

def cmb(n, r):
	if n - r < r: r = n - r
	if r == 0: return 1
	if r == 1: return n

	numerator = [n - r + k + 1 for k in range(r)]
	denominator = [k + 1 for k in range(r)]

	for p in range(2,r+1):
		pivot = denominator[p - 1]
		if pivot > 1:
			offset = (n - r) % p
			for k in range(p-1,r,p):
				numerator[k - offset] /= pivot
				denominator[k] /= pivot

	result = 1
	for k in range(r):
		if numerator[k] > 1:
			result *= int(numerator[k])

	return result

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

l = factorization(m)

ans = 1

for _,c in l:
	ans = ans * cmb(c+n-1,c) % MOD

print(ans)

Submission status: Wrong Answer

Solution code:
def factorize(n):
    from collections import defaultdict
    d = defaultdict(int)
    for i in range(2, int(n**0.5)+1):
        while n%i==0:
            d[i] += 1
            n //= i
        if not n:
            break
    if n>1:
        d[n] += 1
    return d


N, M = map(int, input().split())
d = factorize(M)

mod = 10**9+7
n = N+10000
fac = [1]*(n+1)
rev = [1]*(n+1)
 
for i in range(1,N+1):
  fac[i] = i*fac[i-1]%mod
  rev[i] = pow(fac[i], mod-2, mod)
 
comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%mod

v = 1
for i in d.values():
    v *= comb(i+N-1, i)
    v %= mod
print(v)

Submission status: Wrong Answer

Solution code:
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

MOD = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, 10**5+1000):
    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):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD

def solve():
    N, M = map(int, input().split())
    l = factorize(M)
    
    ans = 1
    for _, c in l:
        ans = ans * cmb(c+N-1, c)
        
    return ans

print(solve())

Submission status: Wrong Answer

Solution code:
def comb(n,m):
  if m == 0:
    return 1
  return comb(n-1,m-1)*n // m
n,m=map(int,input().split())
mod=10**9+7
def factorization(x):
  ans=[]
  for i in range(2,int(x**0.5)+2):
    if x%i==0:
      cnt=0
      while x%i==0:
        x//=i
        cnt+=1
      ans.append([i,cnt])
      if x==1:
        break
  if x!=1:
    ans.append([x,1])
  if ans==[]:
    ans.append([x,1])
  return ans
g=factorization(m)
ans=1
for i in g:
  ans=(ans*(comb(i[1]+n-1,i[1])%mod))%mod
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
mod=10**9+7
def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k:return 0
  if n==0 and k==0:return 1
  a=factorial(n)%p
  b=factorial(k)%p
  c=factorial(n-k)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0:
    return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return (d*d)%p
  else:
    return (a*power_func(a,b-1,p))%p
def factorization(x):
  ans=[]
  for i in range(2,int(x**0.5)+2):
    if x%i==0:
      cnt=0
      while x%i==0:
        x//=i
        cnt+=1
      ans.append([i,cnt])
      if x==1:
        break
  if ans==[]:
    ans.append([x,1])
  return ans
g=factorization(m)
ans=1
for i in g:
  ans*=comb(i[1]+n-1,i[1],mod)
  ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
mod=10**9+7
def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k:return 0
  if n==0 and k==0:return 1
  a=factorial(n)%p
  b=factorial(k)%p
  c=factorial(n-k)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0:
    return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return (d*d)%p
  else:
    return (a*power_func(a,b-1,p))%p
def factorization(x):
  ans=[]
  for i in range(2,int(x**0.5)+2):
    if x%i==0:
      cnt=0
      while x%i==0:
        x//=i
        cnt+=1
      ans.append([i,cnt])
  if x!=1:
    ans.append([x,1])
  if ans==[]:
    ans.append([n,1])
  return ans
g=factorization(m)
ans=1
for i in g:
  ans*=comb(i[1]+n-1,i[1],mod)
  ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
mod=10**9+7
def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k:return 0
  if n==0 and k==0:return 1
  a=factorial(n)%p
  b=factorial(k)%p
  c=factorial(n-k)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0:
    return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return (d*d)%p
  else:
    return (a*power_func(a,b-1,p))%p
def factorization(x):
  ans=[]
  for i in range(2,int(x**0.5)+2):
    if x%i==0:
      cnt=0
      while x%i==0:
        x//=i
        cnt+=1
      ans.append([i,cnt])
  return ans
g=factorization(m)
ans=1
for i in g:
  ans*=comb(i[1]+n-1,i[1],mod)
  ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

a=factorization(M)
A=[]
for i in range(len(a)):
  A.append(a[i][1])
ans=1
for i in A:
  d=cmb(i+N-1,i)
  ans*=d%(10**9+7)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
mod=10**9+7
def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k:return 0
  if n==0 and k==0:return 1
  a=factorial(n)%p
  b=factorial(k)%p
  c=factorial(n-k)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0:
    return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return (d*d)%p
  else:
    return (a*power_func(a,b-1,p))%p
def factorization(x):
  ans=[]
  for i in range(2,int(x**0.5)+2):
    if x%i==0:
      cnt=0
      while x%i==0:
        x//=i
        cnt+=1
      ans.append([i,cnt])
  return ans
g=factorization(m)
ans=1
print(g)
for i in g:
  ans*=comb(i[1]+n-1,i[1],mod)
  ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
from math import factorial
def f(n,r):
  return factorial(n) // factorial(r) // factorial(n - r)

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

a=factorization(M)
A=[]
for i in range(len(a)):
  A.append(a[i][1])
ans=1
for i in A:
  d=f(i+N-1,i)
  ans*=d%(10**9+7)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
def ord(N,n):#N,nは正の整数、Nで割り切れる回数、許容はN^1000
    if n%N!=0:
        return 0
    else:
        return 1+ord(N,n//N)

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

primelist=get_sieve_of_eratosthenes_new(32*10**2)

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

mod = 10**9+7 #出力の制限
N = 2*10**5
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 )


def main():
    N,M=map(int,input().split())
    product=1
    for i in range(0,len(primelist)):
        product=(product*cmb(ord(primelist[i],M)+N-1,N-1,mod))%mod
        M=M//primelist[i]**ord(primelist[i],M)
    if M!=1:
        product=(product*N)//mod
    print(product)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
import math
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
d = defaultdict(int)
M_ = M
MOD = 10 ** 9 + 7
while True:
    for i in range(2, int(M_ ** 0.5) + 1):
        if M_ % i == 0:
            M_ //= i
            d[i] += 1
            break
    else:
        d[M_] += 1
        break

def nCr(n, r):
    return math.factorial(n) // math.factorial(n - r) // math.factorial(r)

ans = 1
nCr_d = {}
for key, val in d.items():
    if (val+N-1, N-1) not in nCr_d:
        nCr_d[(val+N-1, N-1)] = nCr(val+N-1, N-1)
    ans = (ans * nCr_d[(val+N-1, N-1)]) % MOD

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
import math
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
d = defaultdict(int)
M_ = M
MOD = 10 ** 9 + 7
while True:
    for i in range(2, int(M_ ** 0.5) + 1):
        if M_ % i == 0:
            M_ //= i
            d[i] += 1
            break
    else:
        d[M_] += 1
        break

def nCr(n, r):
    return math.factorial(n) // math.factorial(n - r) // math.factorial(r)

ans = 1
for key, val in d.items():
    ans = (ans * nCr(val+N-1, N-1)) % MOD

print(ans)

Submission status: Wrong Answer

Solution code:

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

def cmb(n,m):
    ans=1
    for i in range(n,n-m,-1):
        ans*=i
    for i in range(1,m+1):
        ans //=i
    return ans





def resolve():
    N,M=map(int,input().split())
    ans=1
    md=10**9+7
    for i in factorization(M):
        nn=i[1]+N-1
        ans *= cmb(nn,i[1])
        ans %=  md

    print(ans)
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:

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

def cmb(n,m):
    ans=1
    for i in range(n,n-m,-1):
        ans*=i
    for i in range(1,m+1):
        ans //=i
    return ans





def resolve():
    N,M=map(int,input().split())
    ans=1
    for i in factorization(M):
        nn=i[1]+N-1
        ans *= cmb(nn,i[1])
        ans %=  1000000007

    print(ans %  1000000007)
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:

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

def cmb(n,m):
    ans=1
    for i in range(n,n-m,-1):
        ans*=i
    for i in range(1,m+1):
        ans //=i
    return ans





def resolve():
    N,M=map(int,input().split())
    ans=1
    for i in factorization(M):
        nn=i[1]+N-1
        ans *= cmb(nn,min(N,i[1]))
        ans %=  1000000007

    print(ans %  1000000007)
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:

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

def cmb(n,m):
    ans=1
    for i in range(n,n-m,-1):
        ans*=i
    for i in range(1,m+1):
        ans //=i
    return ans





def resolve():
    N,M=map(int,input().split())
    ans=1
    for i in factorization(M):
        nn=i[1]+N-1
        ans *= cmb(nn,min(N,i[1]))
        ans %=  1000000007

    print(ans)
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
# 逆元
# a^{-1} mod を計算する
def mod_inv(a, m):
    return pow(a, m-2, m)


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

    # 10C3 = (10*9*8)/(3*2*1)
    # 10*9*8 -> ans_mul
    # 3*2*1 -> ans_div
    ans_mul = 1
    ans_div = 1
    for i in range(b):
        ans_mul *= a - i
        ans_div *= i + 1
        ans_mul %= MOD
        ans_div %= MOD
    # ans_mul / ans_div をやりたい
    # ans_div の逆元を使って求める
    ans = ans_mul * mod_inv(ans_div, MOD)
    return ans


N, M = map(int, input().split())
MOD = 10**9+7
# M を素因数分解
rest = M
ans = 1
for i in range(2, int(M ** 0.5) + 1):
    cnt = 0
    while rest % i == 0:
        cnt += 1
        rest //= i
    # cnt が 2^X 1とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)

Submission status: Wrong Answer

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

# 逆元
# a^{-1} mod を計算する
def mod_inv(a, m):
    return pow(a, m-2, m) % m


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

    # 10C3 = (10*9*8)/(3*2*1)
    # 10*9*8 -> ans_mul
    # 3*2*1 -> ans_div
    ans_mul = 1
    ans_div = 1
    for i in range(b):
        ans_mul *= a - i
        ans_div *= i + 1
        ans_mul %= MOD
        ans_div %= MOD
    # ans_mul / ans_div をやりたい
    # ans_div の逆元を使って求める
    ans = ans_mul * mod_inv(ans_div, MOD)
    return ans


# M を素因数分解
m_nokori = M
ans = 1
for i in range(2, int(M**0.5)+1):
    if m_nokori == 1:
        break
    cnt = 0
    while m_nokori % i == 0:
        cnt += 1
        m_nokori //= i
    # cnt が 2^X とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)

Submission status: Wrong Answer

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(cnt)

    if temp!=1:
        arr.append(1)

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

    return arr
     
p=factorization(M)#素因数分解して次数を調べる

    
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

mod=10**9 + 7
fact=[1,1]
factinv=[1,1]
inv=[0,1]
 
N2=N+max(p)    

for i in range(2, N2 + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)
    

        
ans=1
for i in range(len(p)):
    ans*=cmb(p[i]+N-1,p[i],mod)
    ans%=mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
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
import collections
from scipy.misc import comb  
N,M = map(int,input().split())

arr = collections.Counter(prime_factorize(M))
ans = 1
for i in arr:
  ans = ans * (arr[i]+1)

a = comb(ans, N-1, exact=True)
print(int(a))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict

# mod mでの二項係数を求める
class BiCoeff(object):
    def __init__(self, MAX, m):
        super(BiCoeff, self).__init__()
        fac = [0]*MAX
        finv = [0]*MAX
        inv = [0]*MAX

        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2,MAX):
            fac[i] = (fac[i-1]*i)%m
            inv[i] = m - (inv[m%i] * (m//i))%m
            finv[i] = (finv[i-1] * inv[i])%m

        self.MAX = MAX
        self.m = m
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def calc(self,n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return (self.fac[n] * (self.finv[k]*self.finv[n-k])%self.m)%self.m

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

pl = defaultdict(int)
x = m
p = 2
while p*p<x:
    while x%p==0:
        pl[p] += 1
        x //= p
    p += 1
if x>1:
    pl[x] += 1


coeff = BiCoeff(10**6, MOD)
res = 1
for k in pl:
    res *= coeff.calc(n+pl[k]-1, pl[k])
    res %= MOD
print(res)

Submission status: Wrong Answer

Solution code:
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

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
 
MOD = 10 ** 9 + 7
SIZE = 10 ** 5 * 2 + 1
g1 = [1, 1]
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, SIZE + 1 ):
  g1.append((g1[-1] * i) % MOD)
  inverse.append((-inverse[MOD % i] * (MOD // i) ) % MOD)
  g2.append((g2[-1] * inverse[-1]) % MOD)

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

answer = 1
for p, a in factorization(M):
  answer = (answer * cmb(N - 1 + a, a, MOD)) % MOD

print(answer)

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter

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

K = 50
fact = [0] * (n+1+K)
ifact = [0] * (n+1+K)
fact[0] = 1
for i in range(1,n+1+K):
    fact[i] = fact[i-1] * i % mod
ifact[n+K] = pow(fact[n+K], mod-2, mod)
for i in reversed(range(1,n+1+K)):
    ifact[i-1] = ifact[i] * i % mod

def comb(n, k):
    return fact[n] * ifact[n-k] % mod * ifact[k] % mod

def getprime(n):
    primes = []
    i = 2
    while n >= i * i:
        while n % i == 0:
            n //= i
            primes.append(i)
        i += 1
    if n != 1:
        primes.append(n)
    return primes

ans = 1
counter = Counter(getprime(m))
print(counter)
for k in counter.values():
    ans *= comb(n+k-1, k)
    ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
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
 
N,M=map(int,input().split())
if M==1:
  print(1)
else:
  primes0=prime_factorize(M)
  keys=list(set(primes0))
  primes={}
  for i in range(len(keys)):
    k=keys[i]
    primes[k]=0
    for j in range(len(primes0)):
      if primes0[j]==k:
        primes[k]+=1
 
  def cmb(n, k, mod, fac, ifac): #calc nCk under mod
      if n < k or n < 0 or k < 0:
          return 0
      else: 
          k = min(k, n-k)
          return fac[n] * ifac[k] * ifac[n-k] % mod