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 sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, r)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


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 not arr:
        arr.append([n, 1])
    
    return arr


def solve():
    N, M = map(int, rl().split())
    MOD = 10 ** 9 + 7
    
    facts = factorization(M)
    com = Combination(2 * 10 ** 5, MOD)
    
    ans = 1
    for _, exp in facts:
        ans = ans * com.ncr(exp + N - 1, exp) % MOD
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def prime_factorization(n):
    res = []
    for i in range(2, int(pow(n, 0.5))+1):
        if n % i: continue
        ex = 0
        while n % i == 0:
            n = n // i
            ex += 1
        res.append((i, ex))
    if n != 1:
        res.append((n, 1))
    return res

def mcomb(n, k, mod):
    def mfac(l, r, mod):
        ans = l
        for i in reversed(range(r, l)):
            ans *= i
            ans %= mod
        return ans

    A = mfac(n, n-k+1, mod)
    B = mfac(k, 1, mod)
    # B = mpow(B,mod-2,mod)
    B = pow(B, mod-2, mod)
    return A * B % mod

def solve():
    N, M = MI()
    fact = prime_factorization(M)
    MOD = 1000000007

    ans = 1
    for num, ex in fact:
        ans = ans * mcomb(ex+N-1, N-1, MOD)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
def fact(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 find_power(n,mod=10**9+7):
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n,mod=10**9+7):
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist
mod = 10**9+7
NUM = (4*10**5)+100
p_lis=find_power(NUM,mod)
ip_lis=find_inv_power(NUM,mod)

def comb(n,r,mod=10**9+7):
    if n<r:
        return 0
    elif n>=r:
        return (p_lis[n]*ip_lis[r]*ip_lis[n-r])%(mod)

ans=1
for itm in fact(m):
    _, x = itm
    ans*=comb(x+n-1,n-1)
    ans%=mod

print(ans)

Submission status: Wrong Answer

Solution code:
import math
NUM = 10**9 + 7
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

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

ans = 1

arr = factorization(m)
for i in arr:
    _, a = i[0], i[1]
    ans *= comb(a+n-1, a)
    ans %= NUM

print(ans)

Submission status: Wrong Answer

Solution code:
import math

def factorize(n):
    d = {}
    temp = int(math.sqrt(n))+1
    for i in range(2, temp):
        while n%i== 0:
            n //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[n] = 1
    else:
        if n in d:
            d[n] += 1
        elif n != 1:
            d[n] =1
    return d

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

def cmb1(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+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 )

d = factorize(m)
ans = 1
for v in d.values():
    ans *= cmb1(v+n-1, v, mod)
    ans %= mod
print(ans%mod)

Submission status: Wrong Answer

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


MOD = 10**9+7
lim = 200000
inv_t = [-1 for i in range(lim+1)]
factrial = [-1 for i in range(lim+1)]
factrial_inv = [-1 for i in range(lim+1)]


def set_inv(max=lim):
    inv_t[0] = 0
    for i in range(1, max):
        inv_t[i] == mod_inv(i)


def mod_inv(x, mod=MOD):
    y, u, v, _x = mod, 1, 0, x
    while y:
        t = _x//y
        _x -= t*y
        _x, y = y, _x
        u -= t*v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u


def mod_pow(a, n, mod=MOD):
    res = 1
    while n:
        if n & 1:
            res = res*a % mod
        a = a*a % mod
        n >>= 1
    return res


def set_factrial(max=lim, mod=MOD):
    c = 1
    factrial[0] = factrial_inv[0] = 1
    for i in range(1, max):
        c *= i
        c %= mod
        factrial[i] = c
        factrial_inv[i] = mod_inv(c, mod)


def comb(a, b, mod=MOD):
    if factrial[0] == -1:
        set_factrial()
    return (factrial[a]*factrial_inv[b]*factrial_inv[a-b]) % mod


n, m = [int(_) for _ in input().split()]
ans = 1
for p, e in prime_factor(m):
    ans *= comb(n-1+e, e)
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y // 2) ** 2 % mod
    else            : return power(x, y // 2) ** 2 * x % mod

mod = 10 ** 9 + 7

N = 10 ** 6
factorial = [1]
for i in range(1, N):
    factorial.append(factorial[i - 1] * i % mod)

inverseFactorial = [0] * N
inverseFactorial[N - 1] = power(factorial[N - 1], mod - 2)
for i in range(N - 2, -1, -1):
    inverseFactorial[i] = inverseFactorial[i + 1] * (i + 1) % mod

def comb(x, y):
    return factorial[x] * inverseFactorial[y] * inverseFactorial[x - y] % mod

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

facts = factorization(m)

ans = 1
for a, b in facts:
    ans *= comb(n+b-1, b)
    ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def prime_factorization(n):
    res = []
    for i in range(2, int(pow(n, 0.5))+1):
        if n % i: continue
        ex = 0
        while n % i == 0:
            n = n // i
            ex += 1
        res.append((i, ex))
    if n != 1:
        res.append((n, 1))
    return res

def mcomb(n, k, mod):
    def mfac(l, r, mod):
        ans = l
        for i in reversed(range(r, l)):
            ans *= i
            ans %= mod
        return ans

    A = mfac(n,n-k+1,mod)
    B = mfac(k,1,mod)
    # B = mpow(B,mod-2,mod)
    B = pow(B, mod-2, mod)
    return A * B % mod

def solve():
    n, m = MI()
    fact = prime_factorization(m)
    # print(fact)
    mod = 1000000007
    ans = 1
    for num, ex in fact:
        # print(ex, mcomb(ex+n-2, n-1, mod))
        ans *= mcomb(ex+n-1, n-1, mod) % mod
    print(ans % mod)


if __name__ == '__main__':
    solve()

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 #出力の制限
N = 10**5+100
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 )
N,M=map(int,input().split())
A=factorization(M)
ans=1
for i in range(len(A)):
 ans*=cmb(N+A[i][1]-1, N-1, mod)
 ans%=(10**9+7)
print(ans)

Submission status: Wrong Answer

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

f = [1 for _ in range(10 ** 7)]
f_inv = [1 for _ in range(10 ** 7)]
for i in range(1, 10 ** 6):
    f[i] = f[i-1] * i % mod
    f_inv[i] = pow(f[i], mod-2, mod)

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

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

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

    return arr

arr = factorization(m)

ans = 1
for _, k in arr:
    ans *= comb(n+k-1, k)
    ans %= mod

print(ans)

Submission status: Wrong Answer

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

# 因数分解
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

# 重複組み合わせ
# フェルマーの小定理nHk≡(n+k−1)!⋅(k!)M−2⋅((n−1)!)M−2(modM)
def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    if n<=0 or k<0 or n<k: return 0
    if n==1 or k==0: return 1
    a=factorial(n+k-1) %p
    b=factorial(k) %p
    c=factorial(n-1) %p
    return (a*pow(b,p-2,p)*pow(c,p-2,p))%p

a = prime_factorize(M)
c = Counter(a)
l = []
ans = 1
for i in c.values():
    # それぞれの余りがわかっている時、その積の余りを求める時は以下
    ans *= comb(N,i,10**9+7)
    ans %= 10**9+7

print(ans%(10**9+7))

Submission status: Wrong Answer

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

# 因数分解
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

# 重複組み合わせ
# フェルマーの小定理nHk≡(n+k−1)!⋅(k!)M−2⋅((n−1)!)M−2(modM)
def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    if n<=0 or k<0 or n<k: return 0
    if n==1 or k==0: return 1
    a=factorial(n+k-1) %p
    b=factorial(k) %p
    c=factorial(n-1) %p
    return (a*pow(b,p-2,p)*pow(c,p-2,p))%p

a = prime_factorize(M)
c = Counter(a)
l = []
ans = 1
for i in c.values():
    # それぞれの余りがわかっている時、その積の余りを求める時は以下
    ans *= comb(N,i,10**9+7)
    ans %= 10**9+7

print(ans)

Submission status: Wrong Answer

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

# 因数分解
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

# 重複組み合わせ
# フェルマーの小定理nHk≡(n+k−1)!⋅(k!)M−2⋅((n−1)!)M−2(modM)
def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    if n<=0 or k<0 or n<k: return 0
    if n==1 or k==0: return 1
    a=factorial(n+k-1) %p
    b=factorial(k) %p
    c=factorial(n-1) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p

a = prime_factorize(M)
c = Counter(a)
l = []
ans = 1
for i in c.values():
    # それぞれの余りがわかっている時、その積の余りを求める時は以下
    ans *= comb(N,i,10**9+7)
    ans %= 10**9+7

print(ans)

Submission status: Wrong Answer

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

# 因数分解
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

# 重複組み合わせ
# フェルマーの小定理nHk≡(n+k−1)!⋅(k!)M−2⋅((n−1)!)M−2(modM)
def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=factorial(n+k-1) %p
    b=factorial(k) %p
    c=factorial(n-1) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p

a = prime_factorize(M)
c = Counter(a)
l = []
ans = 1
for i in c.values():
    ans *= comb(N,i,10**9+7)
    ans %= 10**9+7

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import time

TEST = True
TEST = False


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

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]

for i in range(2, 150000):
    fac.append(fac[i-1] * i % MOD)
    inv.append((MOD-inv[MOD%i]*(MOD//i)) % MOD)
    finv.append(finv[i-1]*inv[i]%MOD)


def binom(n, k):
    ans = (fac[n] * finv[n-k]) % MOD
    return (ans * finv[k]) % MOD


ans = 1
y = m
x = 1
while y > 1:
    if x*x > y:
        ans = (ans*binom(n,1)) % MOD
        break
    x += 1
    exp = 0
    while y % x == 0:
        y /= x
        exp += 1
    ans = (ans*binom(exp+n-1, exp)) % MOD
    if TEST:
        print("x = " + str(x) + ", ans = " + str(ans) )

if y == m:
    ans = n

print(ans)

#runTime = time.time() - start
#print("My answer is  " + str(ans))
#print("The running time is " + str(runTime) + " sec")

Submission status: Wrong Answer

Solution code:
import math
import time


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

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]

for i in range(2, 150000):
    fac.append(fac[i-1] * i % MOD)
    inv.append((MOD-inv[MOD%i]*(MOD//i)) % MOD)
    finv.append(finv[i-1]*inv[i]%MOD)


def binom(n, k):
    ans = (fac[n] * finv[n-k]) % MOD
    return (ans * finv[k]) % MOD


ans = 1
y = m
x = 1
while y > 1:
    x += 1
    exp = 0
    while y % x == 0:
        y /= x
        exp += 1
    ans = (ans*binom(exp+n-1, exp)) % MOD
#    print("x = " + str(x) + ", ans = " + str(ans) )

if y == m:
    ans = n

print(ans)

#runTime = time.time() - start
#print("My answer is  " + str(ans))
#print("The running time is " + str(runTime) + " sec")

Submission status: Wrong Answer

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def factorization(n):
    primen, degree, primend = [], [], []
    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
            primen.append(i)
            degree.append(cnt)
            primend.append([i,cnt])
    if temp!=1:
        primen.append(temp)
        degree.append(1)
        primend.append([temp,1])
    if primen==[]:
        primen.append(n)
        degree.append(1)
        primend.append([n,1])
    return degree
#    return primen,degree


def main():
    N, M = map(int, input().split())
    mod = 10**9+7               # mod素数
    Mf = factorization(M)
    l = max(Mf)
    Comb=[1]*(l+1)
    for i in range(1,l+1):
        tmp = Comb[i-1]
        tmp *= N-1+i
        tmp *= pow(i, mod-2, mod)
        Comb[i] = tmp%mod
    ret = 1
    for i in Mf:
        ret *= Comb[i]
        ret %= mod
    print(ret)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import time


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

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]

for i in range(2, 150000):
    fac.append(fac[i-1] * i % MOD)
    inv.append((MOD-inv[MOD%i]*(MOD//i)) % MOD)
    finv.append(finv[i-1]*inv[i]%MOD)


def binom(n, k):
    ans = (fac[n] * finv[n-k]) % MOD
    return (ans * finv[k]) % MOD


ans = 1
y = m
for x in range(2, int(math.sqrt(m))+2):
    exp = 0
    while y % x == 0:
        y /= x
        exp += 1
    ans = (ans*binom(exp+n-1, exp)) % MOD
#    print("x = " + str(x) + ", ans = " + str(ans) )

if y == m:
    ans = n

print(ans)

#runTime = time.time() - start
#print("My answer is  " + str(ans))
#print("The running time is " + str(runTime) + " sec")

Submission status: Wrong Answer

Solution code:
import math
import time


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

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]

for i in range(2, 150000):
    fac.append(fac[i-1] * i % MOD)
    inv.append((MOD-inv[MOD%i]*(MOD//i)) % MOD)
    finv.append(finv[i-1]*inv[i]%MOD)


def binom(n, k):
    ans = (fac[n] * finv[n-k]) % MOD
    return (ans * finv[k]) % MOD


ans = 1
y = m
for x in range(2, int(math.sqrt(m))+2):
    exp = 0
    while y % x == 0:
        y /= x
        exp += 1
    ans = (ans*binom(exp+n-1, exp)) % MOD
#    print("x = " + str(x) + ", ans = " + str(ans) )

print(ans)

#runTime = time.time() - start
#print("My answer is  " + str(ans))
#print("The running time is " + str(runTime) + " sec")

Submission status: Wrong Answer

Solution code:
import math
import time


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

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]

for i in range(2, 150000):
    fac.append(fac[i-1] * i % MOD)
    inv.append((MOD-inv[MOD%i]*(MOD//i)) % MOD)
    finv.append(finv[i-1]*inv[i]%MOD)


def binom(n, k):
    ans = (fac[n] * finv[n-k]) % MOD
    return (ans * finv[k]) % MOD


ans = 1
y = m
for x in range(2, int(math.sqrt(m))+1):
    exp = 0
    while y % x == 0:
        y /= x
        exp += 1
    ans = (ans*binom(exp+n-1, exp)) % MOD
#    print("x = " + str(x) + ", ans = " + str(ans) )

print(ans)

#runTime = time.time() - start
#print("My answer is  " + str(ans))
#print("The running time is " + str(runTime) + " sec")

Submission status: Wrong Answer

Solution code:
import sys, math
from collections import defaultdict
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

class Combination:
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

def factorization(n):
    if n == 1: print("n must be > 1")
    arr = []
    temp = n
    for i in range(2, int(round(n ** 0.5))+1):
        cnt = 0
        while temp % i == 0:
            cnt += 1
            temp //= i
        if cnt > 0: arr.append([i, cnt])
    if temp != 1: arr.append([temp, 1])
    if arr == []: arr.append([n, 1])
    return arr


def main():
    comb = Combination(10**6)
    N, M = map(int, input().split())
    primes = factorization(M)

    if M == 1:
        print(1)
        return
    ans = 1
    for _, num in primes:
        ans *= comb(num + (N - 1), num)
        ans %= mod
    print(ans)





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys, math
from collections import defaultdict
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

class Combination:
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

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


def main():
    comb = Combination(10**6)
    N, M = map(int, input().split())
    primes = factorization(M)

    ans = 1
    for _, num in primes:
        ans *= comb(num + (N - 1), num)
        ans %= mod
    print(ans)





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

class Combination:
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

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 main():
    comb = Combination(5 * 10**5)
    N, M = map(int, input().split())
    primes = factorization(M)

    ans = 1
    for _, num in primes:
        ans *= comb(num + (N - 1), num)
        ans %= mod
    print(ans)





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()

    d = {}
    m = M
    for i in range(2,int(math.sqrt(M))+1):
        while m % i == 0:
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
            m //= i
    if m > 1:
        d[m] = 1

    a = [0]
    b = [0]
    c = 1
    for i in range(1,N+int(math.log(M,2)) +1):
        c = (c * i) % MOD
        a.append(c)
        b.append(pow(c,MOD-2,MOD))

    ans = 1
    for v in d.values():
        ans = (ans * a[N+v-1] * b[v]* b[N-1]) % MOD
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M = map(int,(input().split()))
MOD = 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

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]
 
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]
 
def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

fac = factorization(M)
ans = 1
for i in fac:
    ans = (ans * nCr(i[1]+N-1,i[1]))%MOD
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from collections import Counter


def ncr(n, r, mod):
    ret = 1
    for i in range(1, r+1):
        ret = (ret * (n-i+1) * pow(i, mod-2, mod)) % mod
    return ret


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    mod = 10**9+7
    C = Counter()

    i = 2
    r = int(m**(1/2))
    while 1 < m:
        while m % i == 0:
            C[i] += 1
            m //= i
        if r < i:
            C[m] = 1
            break
        i += 1

    ret = 1
    for v, c in C.items():
        ret *= ncr(n+c-1, min(n-1, c), mod)
        ret %= mod

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from collections import Counter


def ncr(n, r, mod):
    ret = 1
    for i in range(1, r+1):
        ret = (ret * (n-i+1) * pow(i, mod-2, mod)) % mod
    return ret


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    mod = 10**9+7
    C = Counter()

    i = 2
    while 1 < m:
        while m % i == 0:
            C[i] += 1
            m //= i
        i += 1

    ret = 1
    for v, c in C.items():
        ret *= ncr(n+c-1, min(n, c), mod)
        ret %= mod

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
def prime_factorizarion(n):
	arr = []
	temp = n
	for i in range(2, int(n**0.5)+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 modInv(a,mod):
    return pow(a,mod-2,mod)

def nCr(n,r,mod):
    r=min(r,n-r)
    if r==0:
        return 1
    if r==1:
        return n
    numer=1
    denom=1
    for i in range(r):
        numer=(n-i)*numer%mod
        denom=(i+1)*denom%mod
    return numer*modInv(denom,mod)%mod

mod=10**9+7
N,M=map(int,input().split())

if M==1:
    print(1)
    exit()

prime_divisors=prime_factorizarion(M)
ans=1
for prime,num in prime_divisors:
    ans=(ans*nCr(num+N-1,num,mod))%mod
print(ans,prime_divisors)