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:
# -*- coding: utf-8 -*-
from sys import stdin
import math

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N, M = ds_in()
MOD = 10**9 + 7

def factorize(n):
    if n == 1:
        return [(1, 1)]
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

fct = factorize(M)

def recursive_square(n, m, p):
    """ n**p (mod m) """
    if p == 0:
        return 1 % m
    if p % 2 == 0:
        root = recursive_square(n, m, p//2) % m 
        return (root ** 2) % m
    else:
        return ((n % m) * recursive_square(n, m, p-1)) % m

Inv = dict([[1,1]]) # 逆元

# 組み合わせ
def combination(n, r):
    val = 1
    for i in range(1, r+1):
        if i not in Inv.keys():
            Inv[i] = recursive_square(i, MOD, MOD-2)
        val = (((val * (n-i+1)) % MOD) * Inv[i]) % MOD
    return val

ans = 1
for f in fct:
    ans = (ans * combination(N-1+f[1], f[1])) % MOD
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

nn,m=map(int,input().split())
x=primes(int(m**0.5))
y=[]
z=m
for t in x:
    while(z%t==0):
        y.append(t)
        z//=t
if len(y)==0 and m>1:
    y.append(m)
c=collections.Counter(y).values()
ans=1
mod=10**9+7
for t in c:
    ans*=com(t+nn-1,t)
    ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N,M=map(int,raw_input().split())
m=int(math.sqrt(M))+2

mod=10**9+7
fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, 10**5+10000):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, mod-2, mod))
 
 
def ncr(n,r):
	if n < 0 or r < 0 or n < r:
		return 0
	else:
		return (fact[n] * inv_fact[r] * inv_fact[n-r]) %mod

ans=1

for i in range(2,10**5):
	cnt=0
	while M%i==0:
		M/=i
		cnt+=1
	ans*=ncr(N+cnt-1,cnt)
	ans%=mod

print ans

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

nn,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
z=m
for t in x:
    while(z%t==0):
        z//=t
        y.append(t)
if len(y)==0 and m>1:
    y.append(m)
c=collections.Counter(y).values()
ans=1
mod=10**9+7
for t in c:
    ans*=com(t+nn-1,t)
    ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

nn,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
z=m
for t in x:
    while(z%t==0):
        z//=t
        y.append(t)
if len(y)==0:
    y.append(m)
c=list(collections.Counter(y).values())
ans=1
mod=10**9+7
for t in c:
    ans*=com(t+nn-1,t)
    ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

nn,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
z=m
for t in x:
    while(z%t==0):
        z//=t
        y.append(t)
c=list(collections.Counter(y).values())

ans=1
for t in c:
    ans*=com(t+nn-1,t)
mod=10**9+7
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

nn,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
z=m
for t in x:
    while(z%t==0):
        z//=t
        y.append(t)
if len(y)==0:
    y=[z]
c=list(collections.Counter(y).values())

ans=1
for t in c:
    ans*=com(t+nn-1,t)
mod=10**9+7
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import math

N,M=map(int,raw_input().split())
m=int(math.sqrt(M))+10

mod=10**9+7
fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, 10**5+10000):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, mod-2, mod))
 
 
def ncr(n,r):
	if n < 0 or r < 0 or n < r:
		return 0
	else:
		return (fact[n] * inv_fact[r] * inv_fact[n-r]) %mod

ans=1

for i in range(2,m):
	cnt=0
	while M%i==0:
		M/=i
		cnt+=1

	ans*=ncr(N+cnt-1,cnt)
	ans%=mod

print ans

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

n,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
z=m
for t in x:
    if t>z:
        break
    while(z%t==0):
        z//=t
        y.append(t)
if len(y)==0:
    y=[z]
c=list(collections.Counter(y).values())

ans=1
for t in c:
    ans*=com(t+n-1,t)
mod=10**9+7
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

n,m=map(int,input().split())
x=primes(int(m**0.5+1))
x.append(m)
x.sort()
y=[]
for t in x:
    if t>m:
        break
    while(m%t==0):
        m//=t
        y.append(t)
        if m%t!=0:
            break

c=list(collections.Counter(y).values())

ans=1
for t in c:
    ans*=com(t+n-1,t)
mod=10**9+7
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import math

N,M=map(int,raw_input().split())
m=int(math.sqrt(M))+2

mod=10**9+7
fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, 10**6):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, mod-2, mod))
 
 
def ncr(n,r):
	if n < 0 or r < 0 or n < r:
		return 0
	else:
		return (fact[n] * inv_fact[r] * inv_fact[n-r]) %mod

ans=1

for i in range(2,m):
	cnt=0
	while M%i==0:
		M/=i
		cnt+=1

	ans*=ncr(N+cnt-1,cnt)
	ans%=mod

print ans

Submission status: Wrong Answer

Solution code:
import math

N,M=map(int,raw_input().split())
m=int(math.sqrt(M))+2

mod=10**9+7
fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, 10**5+1000):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, mod-2, mod))
 
 
def ncr(n,r):
	if n < 0 or r < 0 or n < r:
		return 0
	else:
		return (fact[n] * inv_fact[r] * inv_fact[n-r]) %mod

ans=1

for i in range(2,m):
	cnt=0
	while M%i==0:
		M/=i
		cnt+=1

	ans*=ncr(N+cnt-1,cnt)
	ans%=mod

print ans

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

n,m=map(int,input().split())
x=primes(int(m**0.5+1))
x.append(m)
x.sort()
y=[]
for t in x:
    if t>m:
        break
    while(m%t==0):
        m//=t
        y.append(t)
c=list(collections.Counter(y).values())

ans=1
for t in c:
    ans*=com(t+n-1,t)
mod=10**9+7
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

n,m=map(int,input().split())
x=primes(int(m**0.5+1))
x.append(m)
y=[]
for t in x:
    while(m%t==0):
        m//=t
        y.append(t)
c=list(collections.Counter(y).values())

ans=1
for t in c:
    ans*=com(t+n-1,t)
mod=10**9+7
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

n,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
for t in x:
    while(m%t==0):
        m//=t
        y.append(t)
c=list(collections.Counter(y).values())

ans=1
for t in c:
    ans*=com(t+n-1,t)
mod=10**9+7
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

n,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
for t in x:
    if t>m:
        break
    while(m%t==0):
        m//=t
        y.append(t)
c=list(collections.Counter(y).values())

ans=1
for t in c:
    ans*=com(t+n-1,t)
mod=10**9+7
print(ans%mod)

Submission status: Wrong Answer

Solution code:
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
warikire = []
kotae = 1

for i in range(100000):
    count = 0
    if m % (i + 2) == 0:
        while m % (i + 2) == 0:
            count = count + 1
            m = m / (i + 2)
        warikire.append(count)
    if m == 1:
        break
if m != 1:
    warikire.append(1)

for j in range(len(warikire)):
    kari = 1
    for k in range(warikire[j]):
        kari = kari * (warikire[j] + n - 1 - k) / (warikire[j] - k)
        if kari > 1000000006:
            kari = kari - (kari // 1000000007) * 1000000007
    kotae = kotae * kari
    if kotae > 1000000006:
        kotae = kotae % 1000000007
print(int(kotae))

Submission status: Wrong Answer

Solution code:
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
warikire = []
kotae = 1

for i in range(100000):
    count = 0
    if m % (i + 2) == 0:
        while m % (i + 2) == 0:
            count = count + 1
            m = m / (i + 2)
        warikire.append(count)
    if m == 1:
        break

for j in range(len(warikire)):
    kari = 1
    for k in range(warikire[j]):
        kari = kari * (warikire[j] + n - 1 - k) / (warikire[j] - k)
        if kari > 1000000006:
            kari = kari - (kari // 1000000007) * 1000000007
    kotae = kotae * kari
    if kotae > 1000000006:
        kotae = kotae % 1000000007
print(int(kotae))

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil, factorial
from collections import Counter

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    for i in range(2, ceil(sqrt(n))+1):
        if not is_prime(i): continue
        q,r = divmod(n, i)
        if r == 0:
            n = q
            factor.append(i)
            q,r = divmod(n, i)
            while r == 0:
                n = q
                factor.append(i)
                q,r = divmod(n, i)
    return factor

def comb(n, r):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
    return a//factorial(r)

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
ans = 1
for v in c.values():
    ans *= comb(v + N - 1, v) % m
print(ans%m)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
bigp = 10**9+7
L1 = []
L2 = []
p = 2
max = np.sqrt(M)
K = M
while p <= max:
    if K%p == 0:
        L1.append(p)
        K = K//p
        if p not in L2:
            L2.append(p)
    else:
        p = p+1

ans = 1
def ModComb(n, r, p):
    N = n%p
    R = r%p
    if N<R:
        return 0
    if N < 2*R:
        R = N-R
    if R == 0:
        return 1
    else:
        return (n*pow(r, p-2, p))%p*ModComb(n-1, r-1, p)


for x in L2:
    primepower = L1.count(x)
    ans *= ModComb(N+primepower-1, primepower, bigp)%bigp

print(ans%bigp)

Submission status: Wrong Answer

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

mod = 10**9 + 7

b = []

c = int(math.sqrt(m))
for i in range(2, 10**5):
    count = 0
    while m % i == 0:
        count += 1
        m = m // i
    b.append(count)

fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n + max(b)+3):
    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 nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 1
for i in b:
    ans *= nck(n-1+i, i)
    ans %= mod

print(ans)

Submission status: Wrong Answer

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

mod = 10**9 + 7

b = []

c = int(math.sqrt(m))
for i in range(2, c+2):
    count = 0
    while m % i == 0:
        count += 1
        m = m // i
    b.append(count)

fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n + max(b)+3):
    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 nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 1
for i in b:
    ans *= nck(n-1+i, i)
    ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Combination:
    def __init__(self, n, 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)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

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


def fs(n):
    f = Counter()
    for i in range(2, math.ceil(math.sqrt(n)) + 1):
        if i > n:
            break
        while n % i == 0:
            f[i] += 1
            n /= i
    return f


mod = 10**9 + 7


def mod_mul(a, b):
    return ((a % mod) * (b % mod)) % mod


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


def mod_div(a, b):
    return mod_mul(a, mod_power(b, mod-2))


def P(n):
    ans = 1
    for i in range(2, n+1):
        ans = mod_mul(ans, i)

    return ans


@mt
def slv(N, M):
    f = fs(M)
    ans = 1
    error_print(f)
    # C = Combination(10**6, mod)

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

    for k in f:
        ans = mod_mul(ans, C(N+f[k]-1, f[k]) % mod)
    return ans


def main():
    N, M = read_int_n()
    print(slv(N, M))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Combination:
    def __init__(self, n, 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)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

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


def fs(n):
    f = Counter()
    for i in range(2, math.ceil(math.sqrt(n)) + 1):
        if i > n:
            break
        while n % i == 0:
            f[i] += 1
            n /= i
    return f


mod = 10**9 + 7


def mod_mul(a, b):
    return ((a % mod) * (b % mod)) % mod


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


def mod_div(a, b):
    return mod_mul(a, mod_power(b, mod-2))


def P(n):
    ans = 1
    for i in range(2, n+1):
        ans = mod_mul(ans, i)

    return ans


@mt
def slv(N, M):
    f = fs(M)
    ans = 1
    error_print(f)
    C = Combination(10**6, mod)
    for k in f:
        ans = mod_mul(ans, C(N+f[k]-1, f[k]))
    return ans


def main():
    N, M = read_int_n()
    print(slv(N, M))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def prime_factorize(n):
    f = defaultdict(lambda: 0)
    f[2] = len(bin(n & -n)) - 3
    i = 3
    k = n >> f[2]
    while 1 < k and i * i < k:
        while True:
            d, m = divmod(k, i)
            if m == 0:
                f[i] += 1
                k = d
            else:
                break
        i += 2
    if k > 1:
        f[k] = 1
    return f


MOD = 1000000007
n, m = map(int, input().split())
pf = prime_factorize(m)
mx = max(pf.values())
f, r = prepare(n + mx - 1, MOD)
ans = 1
for p, e in pf.items():
    ans *= f[n + e - 1]
    ans %= MOD
    ans *= r[n - 1]
    ans %= MOD
    ans *= r[e]
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
warikire = []
kotae = 1

for i in range(100000):
    count = 0
    if m % (i + 2) == 0:
        while m % (i + 2) == 0:
            count = count + 1
            m = m / (i + 2)
        warikire.append(count)
    if m == 1:
        break

for j in range(len(warikire)):
    kari = 1
    for k in range(warikire[j]):
        kari = kari * (warikire[j] + n - 1 - k) / (k + 1)
    kotae = kotae * kari
    if kotae > 1000000006:
        kotae = kotae % 1000000007
print(int(kotae))

Submission status: Wrong Answer

Solution code:
import math

n, m=map(int, input().split())
t = {}
a = int(math.sqrt(m))

s=0

line = [2, 3] + [i%2*2 + i//2 * 6 + 5 for i in range(a//3)] + [m]

for i in line:
    cnt = 0
    while m%i==0:
        m=m//i
        cnt += 1

    if cnt>0:
        t[i]=cnt

    if m==1:
        break

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

out=1
for tk in t.keys():
    out *= combi(t[tk]+n-1, n-1)
#     out = out%(1000000007)
print(out%(1000000007))

Submission status: Wrong Answer

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

map = {}
i = 2
while m != 1:
    if m % i == 0 :
        m = m / i
        if i in map:
            map[i] += 1
        else:
            map[i] = 1
    else:
        i += 1
sum = 1
for i in map:
    c = 1
    d = 1
    e = 1
    for j in range(map[i]):
        c = c * (n - j)
        d = d * (map[i] - j)
    e = e * c // d
    if(map[i] != 1):
        e += n
    sum = sum * e
print(sum % 1000000007)

Submission status: Wrong Answer

Solution code:
import math

n, m=map(int, input().split())
t = {}
a = int(math.sqrt(m))

s=0

line = [2, 3] + [i%2*2 + i//2 * 6 + 5 for i in range(a//3)]

for i in line:
    cnt = 0
    while m%i==0:
        m=m//i
        cnt += 1

    if cnt>0:
        t[i]=cnt

    if m==1:
        break

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

out=1
for tk in t.keys():
    out *= combi(t[tk]+n-1, n-1)
#     out = out%(1000000007)
print(out%(1000000007))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def prime_factorize(n):
    f = defaultdict(lambda: 0)
    f[2] = len(bin(n & -n)) - 3
    i = 3
    k = n >> f[2]
    limit = n ** 0.5
    while 1 < k and i <= limit:
        while True:
            d, m = divmod(k, i)
            if m == 0:
                f[i] += 1
                k = d
            else:
                break
        i += 2
    return f


MOD = 1000000007
n, m = map(int, input().split())
pf = prime_factorize(m)
mx = max(pf.values())
f, r = prepare(n + mx - 1, MOD)
ans = 1
for p, e in pf.items():
    ans *= f[n + e - 1]
    ans %= MOD
    ans *= r[n - 1]
    ans %= MOD
    ans *= r[e]
    ans %= MOD
print(ans)

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

b = []

c = int(math.sqrt(m))
for i in range(2, c+2):
    count = 0
    while m % i == 0:
        count += 1
        m = m // i
    b.append(count)

fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n + max(b)+3):
    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 nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 1
for i in b:
    ans = (ans * nck(n-1+i, n-1)) % mod

print(ans)

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

b = []

c = int(math.sqrt(m))
for i in range(2, c+3):
    count = 0
    while m % i == 0:
        count += 1
        m = m // i
    b.append(count)


fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, 210000):
    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 nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 1
for i in b:
    ans = (ans * nck(n-1+i, n-1)) % mod

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from math import sqrt
n,m = (int(i) for i in input().split())
if n==1: ans = 1
else:
	m2,k,x,mod,ans = m,2,[],10**9+7,1
	while k**2<=m2:
		for i in range(k,int(sqrt(m2))+1):
			if m2%i==0:
				x.append(i)
				k,m2 = i,m2//i
				break
			elif i==int(sqrt(m2)): k = i+1
	x.append(m2)
	c,d = Counter(x).most_common(),[]
	for i,j in c: d.append(j)
	n2 = max(d)+n
	fn,fk = [1]*(n2),[1]*(n2)
	for i in range(n2-1): fn[i+1] = (fn[i]*(i+2))%mod
	def power(n,k):
		if k==1: return n
		elif k%2==0: return power((n**2)%mod,k//2)
		else: return (n*power(n,k-1))%mod
	def comb(n,k):
		if n==0 or k==0 or n==k: return 1
		else: return (((fn[n-1]*fk[n-k-1])%mod)*fk[k-1])%mod
	fk[-1] = power(fn[-1],mod-2)
	for i in range(2,n2+1): fk[-i] = (fk[-i+1]*(n2+2-i))%mod
	for i in d: ans = (ans*comb(i+n-1,i))%mod
print(ans)

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

b = []

c = int(math.sqrt(m))
for i in range(2, c+3):
    count = 0
    while m % i == 0:
        count += 1
        m = m // i
    b.append(count)


fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n+max(b)+3):
    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 nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 1
for i in b:
    ans = (ans * nck(n-1+i, n-1)) % mod

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import math
def factorial_memo(n, p):
  F = [1] * (n + 1)
  for i in range(n):
    F[i + 1] = F[i] * (i + 1) % p
  return F

def inverse(F, p):
  Finv = [x for x in F]
  Finv[-1] = pow(Finv[-1], p - 2, p)
  for i in range(len(F) - 2, 0, -1):
    Finv[i] = Finv[i + 1] * (i + 1) % p
  return Finv

def comb(*A):
  f = F[sum(A)]
  for a in A:
    f *= Finv[a]
  return f % p

def eratosthenes(limit):
  E = [1] * (limit + 1)
  E[0], E[1] = 0, 0
  prime_table = []
  for i, e in enumerate(E):
    if e:
      prime_table.append(i)
      for j in range(i, limit + 1, i):
        E[j] = 0
  return prime_table

N, M = map(int, input().split())
p = 10 ** 9 + 7
limit = int(math.sqrt(M)) + 1
prime_table = eratosthenes(limit)
primes = defaultdict(int)
primes[1] = 0
for prime in prime_table:
  if prime > M:
    break
  while M % prime == 0:
    primes[prime] += 1
    M //= prime
F = factorial_memo(max(primes.values()) + N, p)
Finv = inverse(F, p)
cnt = 1
for c in primes.values():
  cnt *= comb(c, N - 1)
print(cnt % p)