Problem: 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''.

Submission attempts (in order):
from math import *
from collections import *

def Prime_Factorization(M):
    factor_list = []

    for i in range(2, int(sqrt(M)) + 1):
        while M % i == 0:
            factor_list.append(i)
            M = M // i
        if (M == 1):
            break

    return factor_list

def comb(num_object, num_bar):
    return factorial(num_object) // (factorial(num_object - num_bar) * factorial(num_bar))

def all_comb(N, factor_count_list):
    ans = 1
    for factor in factor_count_list:
        ans = (ans * comb(factor_count_list[factor] + N - 1, factor_count_list[factor])) % (10 ** 9 + 7)
    return ans

def main():
    N, M = map(int, input().split())
    factor_list = Prime_Factorization(M)
    
    if factor_list:
        factor_count_list = Counter(factor_list)
        print(all_comb(N, factor_count_list))
    else:
        print(N)

if __name__ == "__main__":
    main()

from math import *
from collections import *

def Prime_Factorization(M):
    factor_list = []

    for i in range(2, int(sqrt(M)) + 1):
        while M % i == 0:
            factor_list.append(i)
            M = M // i
        if (M == 1):
            break

    return factor_list

def comb(num_object, num_bar):
    return factorial(num_object) // (factorial(num_object - num_bar) * factorial(num_bar))

def all_comb(N, factor_count_list):
    ans = 1
    for factor in factor_count_list:
        ans = (ans * comb(factor_count_list[factor] + N - 1, factor_count_list[factor])) % (10 ** 9 + 7)
    return ans

def main():
    N, M = map(int, input().split())
    factor_list = Prime_Factorization(M)
    factor_count_list = Counter(factor_list)
    print(all_comb(N, factor_count_list))

if __name__ == "__main__":
    main()

from math import *

def Prime_Factorization(M):
    factor_count_list = []

    while True:
        root_M = int(sqrt(M))

        for i in range(2, root_M + 1):
            e = 0
            while M % i == 0:
                e += 1
                M = M // i
            if e > 0:
                factor_count_list.append(e)
                break
            if (M == 1):
                break
        else:
            break
    if M > root_M:
        factor_count_list.append(1)

    print(factor_count_list)
    return factor_count_list

def comb(num_object, num_bar):
    return factorial(num_object) // (factorial(num_object - num_bar) * factorial(num_bar))

def all_comb(N, factor_count_list):
    ans = 1
    for factor in factor_count_list:
        ans = (ans * comb(factor + N - 1, factor)) % (10 ** 9 + 7)
    return ans

def main():
    N, M = map(int, input().split())
    factor_count_list = Prime_Factorization(M)

    print(all_comb(N, factor_count_list))

if __name__ == "__main__":
    main()

from math import *

def Prime_Factorization(M):
    factor_count_list = []
    root_M = int(sqrt(M))

    while root_M > 1:
        root_M = int(sqrt(M))

        for i in range(2, root_M + 1):
            e = 0
            while M % i == 0:
                e += 1
                M = M // i
            if e > 0:
                factor_count_list.append(e)
                break
        else:
            break

    if M > root_M:
        factor_count_list.append(1)

    return factor_count_list

def comb(num_object, num_bar):
    numerator = 1

    for i in range(num_bar):
        numerator = (numerator * (num_object - i))

    return  numerator // factorial(num_bar)

def all_comb(N, factor_count_list):
    ans = 1
    for factor in factor_count_list:
        ans = (ans * comb(factor + N - 1, factor)) % (10 ** 9 + 7)
    return ans

def main():
    N, M = map(int, input().split())
    factor_count_list = Prime_Factorization(M)

    print(all_comb(N, factor_count_list))

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted