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

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

D = {}
m = M
for i in range(2, int(M**0.5)+2):
    while m % i == 0:
        D[i] = D.get(i,0)+1
        m = m//i
if D == {}:
    D[M] = 1

d = []
for v in D.values():
    d.append(v)

tmp = [0] * len(d)
for i in range(len(d)):
    tmp[i] = (math.factorial(N-1+d[i]) // (math.factorial(N-1)*math.factorial(d[i])))%(10**9 + 7)

ans = 1
for i in range(len(tmp)):
    ans = ans*tmp[i]%(10**9 +7)
print(ans)

Submission status: Wrong Answer

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

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]]

s=primes(10**5)
t=[]
tt=[]

for i in range(len(s)):
    if m%s[i]==0:
        t.append(s[i])
        tt.append(1)
        m//=s[i]
    while True:
        if m % s[i] == 0:
            tt[-1]+=1
            m //= s[i]
        else:
            break

ans=1
for i in range(len(t)):
    for j in range(tt[i]):
        ans*=j+n
    for j in range(tt[i]):
        ans//=j+1
    ans%=(10**9+7)

print(int(ans))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
mod = 1000000007

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]) % mod

    return result;

s=input()
N, M = map(int, s.split())
M1=M
result=1

for i in range(2, int(math.sqrt(M1)) + 2):
    c=0
    while M % i == 0:
        M /= i
        c=c+1
        
    if c>0:
        result =result * cmb(N+c-1,c) % mod

print(result)

Submission status: Wrong Answer

Solution code:
import math

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

mo=(10**9)+7

yak=[0 for i in range(10**5)]

p=1
for i in range(2,int(m**0.5)+2):

    while m%i==0 :
            m=m//i
            yak[i]+=1
            p=0

if p==1:
    yak[i]=1

#print(y)  
#print(yak[:15])

def k(h):
    c=1
    for i in range(1,h+1):
        c=(c*i)%mo
    return c

#print(k(100))
#print(math.factorial(100)%mo)



#print(k(10))

co=1

for i in range(10**5):
    if yak[i]>0 :
        nn=n+yak[i]-1
        r=yak[i]
        #print(nn)
        #t=(k(nn) // (k(nn - r) * k(r)))%mo
        t=((math.factorial(nn)) // ((math.factorial(nn - r) * math.factorial(r))))%mo
        co=(co*t)%mo

print(co)

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)
    pn = P(N-1)
    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:
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
#     print(cnt)
    if cnt>0:
        t[i]=cnt

    if m==1:
#         s=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:
import math
n,m = map(int, input().split())
ls = []
c = 0
d = 0

for i in range(2,m) :
   if m == 1 :
      break
   while m%i == 0 :
      c += 1
      m = m/i

   ls.append(c)
   c = 0

for j in range(len(ls)) :
   d += math.factorial(ls[j]+n)/math.factorial(n)

print(d)

Submission status: Wrong Answer

Solution code:
num = (10 ** 9) + 7

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

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

prime_upper = int(m ** (1/2) + 50)
prime_dict = {}

check = [False] * prime_upper
prime = [2]

while m % 2 == 0:
    m //= 2
    if not 2 in prime_dict.keys():
        prime_dict[2] = 0
    prime_dict[2] += 1

for j in range(2, prime_upper, 2):
    check[j] = True

for i in range(3, prime_upper, 2):
    if not check[i]:
        prime.append(i)
        while m % i == 0:
            m //= i
            if not i in prime_dict.keys():
                prime_dict[i] = 0
            prime_dict[i] += 1

        for j in range(i, prime_upper, i):
            check[j] = True

if len(prime_dict.values()) != 0:
    value_max = max(prime_dict.values())
    com2 = [[0] * (value_max + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        for j in range(1, value_max + 1):
            if i == 1:
                com2[i][j] = 1
            elif j == 1:
                com2[i][j] = i
            else:
                com2[i][j] = (com2[i][j - 1] + com2[i - 1][j]) % num
    if m != 1:
        ans = n
    else:
        ans = 1
    for key, value in prime_dict.items():
        ans = (ans * com2[n][value]) % num
    print(ans)
else:
    print(n)

Submission status: Wrong Answer

Solution code:
import math

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

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]]

s=primes(10**5)
t=[]
tt=[]

for i in range(len(s)):
    if m%s[i]==0:
        t.append(s[i])
        tt.append(1)
        m//=s[i]
    while True:
        if m % s[i] == 0:
            tt[-1]+=1
            m //= s[i]
        else:
            break

ans=1
for i in range(len(t)):
    ans=ans*((math.factorial(tt[i]+n-1)//math.factorial(tt[i])//math.factorial(n-1)))%(10**9+7)

print(int(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)


#combination---
#nとmは適宜変える

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, n-1)
    ans %= mod

print(ans%mod)

Submission status: Wrong Answer

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


def prime_factors(n):
    i = 2
    factors = defaultdict(int)
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors[i] += 1
    if n > 1:
        factors[n] += 1
    return factors


N, M = [int(elem) for elem in input().split(' ')]

# 素因数分解
prime_numbers = prime_factors(M)
print(prime_numbers)
sum = 1
fac_N_m1 = factorial(N - 1)

for value in prime_numbers.values():
    bunshi = 1
    saisho = value + N - 1
    for _ in range(value):
        bunshi *= saisho
        saisho -= 1
    sum *= (bunshi // factorial(value))
print(sum % (10**9 + 7))

Submission status: Wrong Answer

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

def factorization(m, flag=0):
    m0 = m
    hq = []
    F = defaultdict(int)
    for n in itertools.count(2) if flag else range(2,math.ceil(math.sqrt(m))):

        while hq and hq[0][0] == n:
            heapq.heapreplace(hq,(sum(hq[0]),hq[0][1]))
            if hq[0][0] > n:break
        else:
            while m > 1:
                if m%n:
                    break
                else:
                    m //= n
                    F[n] += 1
            hq.append((n*n,n))
            if m == 1:
                return F
    if m > 1:
        F.update(factorization(m,1))
    if not F:
        F[m] += 1
    return F


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

def solve():
    N, M = map(int, input().split())
    F = factorization(M)
    res = 1
    for n in F.values():
        res *= cmb(N+n-1, n)
    res %= (10**9+7)
    return str(res)

if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M=list(map(int,input().split()))
n=10**5
prime=[i for i in range(n)]
prime[1]=0
for i in range(2,n):
    tmp =i*i
    if prime[tmp]==0 or tmp > n:
        break
    while tmp<n:
        prime[tmp]=0
        tmp+=i

prime=np.array(prime)
prime=prime[prime!=0]

dic={}
for x in prime:
    while M%x==0:
        if dic.get(x,0)==0:
            dic[x]=1
        else:
            dic[x]+=1
        M/=x
    if M==1:
        break
ans = 1
for x in dic.values():
    arr1=[]
    arr2=[]
    for i in range(x,0,-1):
        arr1.append(i+N-1)
        arr2.append(i)
    for i,y in enumerate(arr1):
        for j,z in enumerate(arr2):
            if arr1[i]%arr2[j]==0:
                arr1[i]/=arr2[j]
                arr2[j]=1.0
    for y in arr1:
        ans*=y
        ans%=10**9+7
print(int(ans))

Submission status: Wrong Answer

Solution code:
def mod_combination(n, k, mod):
    # nCk (mod m)
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod

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

yaku = []
flg = 1
while flg == 1:
    for i in range(2,int(m**0.5)+2):
        if m % i == 0:
            m = int(m / i)
            yaku.append(i)
            break
    else:
        yaku.append(int(m))
        flg = 0
yakuset = set(yaku)
num = []
for i in yakuset:
    num.append(yaku.count(i))

mod = int(10e8 + 7)
counter = 1
for i in num:
    rez = mod_combination(n-1+i, i, mod)
    counter = (counter*rez) % mod
print(counter)

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)


#combination---
#nとmは適宜変える

fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n+max(b)+10):
    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, n-1)
    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+3):
    count = 0
    while m % i == 0:
        count += 1
        m = m // i
    b.append(count)


#combination---
#nとmは適宜変える

fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n+max(b)+10):
    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, n-1)
    ans %= mod

print(ans)
print(nck(2, 0))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import heapq
import itertools
import math
from collections import defaultdict
import sys
sys.setrecursionlimit(100000)

def factorization(m):
    m0 = m
    hq = []
    F = defaultdict(int)
    for n in range(2, math.ceil(math.sqrt(m))):

        while hq and hq[0][0] == n:
            heapq.heapreplace(hq,(sum(hq[0]),hq[0][1]))
            if hq[0][0] > n:break
        else:
            while m > 1:
                if m%n:
                    break
                else:
                    m //= n
                    F[n] += 1
            hq.append((n*n,n))
            if m == 1:
                return F
    if not F or m > 1:
        F[m] += 1
    return F


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

def solve():
    N, M = map(int, input().split())
    F = factorization(M)
    res = 1
    for n in F.values():
        res *= cmb(N+n-1, n)
    res %= (10**9+7)
    return str(res)

if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
def mod_combination(n, k, mod):
    # nCk (mod m)
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod

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

yaku = []
flg = 1
while flg == 1:
    for i in range(2,int(m**0.5)+2):
        if m % i == 0:
            m = int(m / i)
            yaku.append(i)
            break
    else:
        yaku.append(m)
        flg = 0
yakuset = set(yaku)
num = []
for i in yakuset:
    num.append(yaku.count(i))

mod = int(10e8 + 7)
counter = 1
for i in num:
    rez = mod_combination(n-1+i, i, mod)
    counter = (counter*rez) % mod
print(counter)

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
    if n != 1:
        for k in range(n - 1):
            kari = kari * (warikire[j] + n - 1 - k) / (n - 1 - k)
    kotae = kotae * kari
if kotae > 1000000006:
    kotae = kotae % 1000000007
print(int(kotae))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M=list(map(int,input().split()))
prime=[i for i in range(4*10**4)]
prime[1]=0
for i in range(2,4*10**4):
    tmp =i*i
    if prime[tmp]==0 or tmp > 4*10**4:
        break
    while tmp<4*10**4:
        prime[tmp]=0
        tmp+=i

prime=np.array(prime)
prime=prime[prime!=0]

dic={}
for x in prime:
    while M%x==0:
        if dic.get(x,0)==0:
            dic[x]=1
        else:
            dic[x]+=1
        M/=x
    if M==1:
        break
ans = 1
for x in dic.values():
    arr1=[]
    arr2=[]
    for i in range(x,0,-1):
        arr1.append(i+N-1)
        arr2.append(i)
    for i,y in enumerate(arr1):
        for j,z in enumerate(arr2):
            if arr1[i]%arr2[j]==0.0:
                arr1[i]/=arr2[j]
                arr2[j]=1.0
    for y in arr1:
        ans*=y
        ans%=10**9+7
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from bisect import bisect_right

# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        

from collections import Counter

n,m = li()

MOD = 10**9+7

# 二項係数の準備
inv = inv_mod(n,MOD)
fac = fact(n,MOD)
facInv = fact_inv(n,inv,MOD)


# Mの素因数リストを作る

def cd(n:int):
    m = 2
    cds = set([n])
    while m*m <= n:
        if n%m == 0:
            cds.add(m)
            cds.add(n//m)
            
        m += 1

    return sorted(list(cds))
    
cds = cd(m)

memo = []

def dfs(m: int, cds: list, res:int,st:list):
    if res == 1:
        memo.append(st)
        
    else:
        idx = bisect_right(cds,st[-1])
        for cdi in cds[:idx]:
            if cdi > st[-1]:
                pass
            else:
                if res%cdi == 0:
                    dfs(m,cds,res//cdi,st+[cdi])
                

# 辞書順にmを作れるオリジナルなセットを作る
for cdi in cds:
    dfs(m,cds,m//cdi,[cdi])

print(len(memo))

ans = 0
for memoi in memo:
    cnt = Counter(memoi)
    cnt_v = list(cnt.values())
    temp = fac[n]
    if len(memoi) <= n:
        for cnt_vi in cnt_v:
            if cnt_vi > 1:
                temp = (temp*facInv[cnt_vi]) % MOD
        temp = (temp*facInv[n-len(memoi)]) % MOD
    
    ans = (ans+temp) % MOD
        
if m==1 or n==1:
    print(1)
else:
    print(ans%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M=list(map(int,input().split()))
prime=[i for i in range(4*10**4)]
prime[1]=0
for i in range(2,4*10**4):
    tmp =i*i
    if prime[tmp]==0 or tmp > 4*10**4:
        break
    while tmp<4*10**4:
        prime[tmp]=0
        tmp+=i

prime=np.array(prime)
prime=prime[prime!=0]

dic={}
for x in prime:
    while M%x==0:
        if dic.get(x,0)==0:
            dic[x]=1
        else:
            dic[x]+=1
        M/=x
    if M==1:
        break
ans = 1
for x in dic.values():
    arr1=[]
    arr2=[]
    for i in range(x,0,-1):
        arr1.append(i+N-1)
        arr2.append(i)
    for i,y in enumerate(arr1):
        for j,z in enumerate(arr2):
            if arr1[i]%arr2[j]==0:
                arr1[i]/=arr2[j]
                arr2[j]=1.0
    for y in arr1:
        ans*=y
        ans%=10**9+7
print(int(ans))

Submission status: Wrong Answer

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

import math

def factorize(n):
    fct = []  # prime factor
    fct_ap = fct.append
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct_ap((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct_ap((n, 1))
    return fct
ans = 1
m_res = factorize(M)
for i in range(len(m_res)):
    e = m_res[i][1]
    f = int(math.factorial(e+N-1) / (math.factorial(e)*math.factorial(N-1)))
    ans = ans * f
    
print(ans % (1000000007))

Submission status: Wrong Answer

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

m2 = int(math.sqrt(m))

n_so = {}

for i in range(2,m2+2):
    t = 0
    while m%i == 0:
        m = int(m/i)
        t += 1
    if t > 0:
        n_so[i] = t
        if m == 1:
            break

su = n_so.values()
max_n = n**sum(su)

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
soi = []
ans = 1
for i in range(2, m):
    if m == 1:
        break
    elif m % i == 0:
        t = 0
        while True:
            if m % i == 0:
                m = m // i
                t += 1
            else:
                break
        soi.append(t)
print(soi)
for i in soi:
    for j in range(min(i, n-1)):
        ans = (ans * (i + n - 1 - j) // (j + 1))
    ans = ans % (10 ** 9 + 7)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        

from collections import Counter

n,m = li()

MOD = 10**9+7

# 二項係数の準備
inv = inv_mod(n,MOD)
fac = fact(n,MOD)
facInv = fact_inv(n,inv,MOD)


# Mの素因数リストを作る

def cd(n:int):
    m = 2
    cds = set([n])
    while m*m <= n:
        if n%m == 0:
            cds.add(m)
            cds.add(n//m)
            
        m += 1

    return sorted(list(cds))
    
cds = cd(m)

memo = []

def dfs(m: int, cds: list, res:int,st:list):
    if res == 1:
        memo.append(st)
        
    else:
        for cdi in cds:
            if cdi > st[-1]:
                pass
            else:
                if res%cdi == 0:
                    dfs(m,cds,res//cdi,st+[cdi])
                

# 辞書順にmを作れるオリジナルなセットを作る
for cdi in cds:
    dfs(m,cds,m//cdi,[cdi])

ans = 0
for memoi in memo:
    cnt = Counter(memoi)
    cnt_v = list(cnt.values())
    temp = fac[n]
    if len(memoi) <= n:
        for cnt_vi in cnt_v:
            temp = (temp*facInv[cnt_vi]) % MOD
        temp = (temp*facInv[n-len(memoi)]) % MOD
    
    ans = (ans+temp) % MOD
        
if m== 1:
    print(1)
else:
    print(ans%MOD)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        

from collections import Counter

n,m = li()

MOD = 10**9+7

# 二項係数の準備
inv = inv_mod(n,MOD)
fac = fact(n,MOD)
facInv = fact_inv(n,inv,MOD)


# Mの素因数リストを作る

def cd(n:int):
    m = 2
    cds = set([n])
    while m*m <= n:
        if n%m == 0:
            cds.add(m)
            cds.add(n//m)
            
        m += 1

    return sorted(list(cds))
    
cds = cd(m)

memo = []

def dfs(m: int, cds: list, res:int,st:list):
    if res == 1:
        memo.append(st)
        
    else:
        for cdi in cds:
            if cdi > st[-1]:
                pass
            else:
                if res%cdi == 0:
                    dfs(m,cds,res//cdi,st+[cdi])
                

# 辞書順にmを作れるオリジナルなセットを作る
for cdi in cds:
    dfs(m,cds,m//cdi,[cdi])

ans = 0
for memoi in memo:
    cnt = Counter(memoi)
    cnt_v = list(cnt.values())
    temp = fac[n]
    if len(memoi) <= n:
        for cnt_vi in cnt_v:
            temp = (temp*facInv[cnt_vi]) % MOD
        temp = (temp*facInv[n-len(memoi)]) % MOD
    
    ans = (ans+temp) % MOD
        
        
print(ans%MOD)

Submission status: Wrong Answer

Solution code:
import math
import collections
def trial_division_sqrt(n):

    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1

    return prime_count
def pc(n, r):
    return math.factorial(n) // (math.factorial(n - r)  * math.factorial(r))
s=0
x,N = map(int,input().split())

li = trial_division_sqrt(N)
li = li.most_common()
ans = 1
for i in range(0, len(li)):
    ans *= pc(li[i][1] + x-1, x-1)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
 
 
mod = 10**9 + 7
 
 
 
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
 
 
n, m = map(int, input().split())
res = 1
fct = factorize(m)
 
for _, count in fct:
    res *= math.factorial(n+count-1) % mod
    res //=  math.factorial(n - 1) % mod
    res //= math.factorial(count) % mod
    res %= mod

print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M=list(map(int,input().split()))
prime=[i for i in range(4*10**4)]
prime[1]=0
for i in range(2,10**5):
    tmp =i*i
    if tmp > 4*10**4:
        break
    while tmp<4*10**4:
        prime[tmp]=0
        tmp+=i

prime=np.array(prime)
prime=prime[prime!=0]

dic={}
for x in prime:
    while M%x==0:
        if dic.get(x,0)==0:
            dic[x]=1
        else:
            dic[x]+=1
        M/=x
    if M==1:
        break
ans = 1
for x in dic.values():
    arr1=[]
    arr2=[]
    for i in range(x,0,-1):
        arr1.append(i+N-1)
        arr2.append(i)
    for i,y in enumerate(arr1):
        for j,z in enumerate(arr2):
            if arr1[i]%arr2[j]==0:
                arr1[i]/=arr2[j]
                arr2[j]=1

    for y in arr1:

        ans*=y
        ans%=10**9+7
print(int(ans))

Submission status: Wrong Answer

Solution code:
num = 10 ** 9 + 7

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

prime_dict = {}

check = [False] * 10000
prime = [2]

while m % 2 == 0:
    m //= 2
    if not 2 in prime_dict.keys():
        prime_dict[2] = 0
    prime_dict[2] += 1

for j in range(2, 10000, 2):
    check[j] = True

for i in range(3, 10000, 2):
    if not check[i]:
        prime.append(i)
        while m % i == 0:
            m //= i
            if not i in prime_dict.keys():
                prime_dict[i] = 0
            prime_dict[i] += 1

        for j in range(i, 10000, i):
            check[j] = True

com2 = [[0] * 50 for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(1, 50):
        if i == 1:
            com2[i][j] = 1
        elif j == 1:
            com2[i][j] = i
        else:
            com2[i][j] = (com2[i][j - 1] + com2[i - 1][j]) % num

ans = 1
for key, value in prime_dict.items():
    ans = (ans * com2[n][value]) % num

print(ans)