Problem:


Score : 400 points

Problem Statement

You are given positive integers N and M.

How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7.

Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

1 \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.

Sample Input 1

2 6

Sample Output 1

4

Four sequences satisfy the condition: \{a_1, a_2\} = \{1, 6\}, \{2, 3\}, \{3, 2\} and \{6, 1\}.

Sample Input 2

3 12

Sample Output 2

18

Sample Input 3

100000 1000000000

Sample Output 3

957870001



Sample input:
2 6


Sample output:
4

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter

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

factor=[]
for f in range(2, 2 * math.ceil(math.sqrt(M))):
	while M % f == 0:
		factor.append(f)
		M //= f

def F(n):
	if n == 1:
		return n
	return n * F(n-1)

def G(n, k):
	if k == 1:
		return n
	return n * G(n-1, k-1)

def H(n, k):
	return G(n+k-1, k) // F(k)

ans = 1
for c in Counter(factor).values():
	ans *= H(N, c)
	ans %= MOD

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import operator
from functools import reduce
from collections import Counter

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

factor=[]
for f in range(2, 1 + math.ceil(math.sqrt(M))):
	while M % f == 0:
		factor.append(f)
		M //= f

def F(n):
	if n == 1:
		return n
	return n * F(n-1)

def C(n, r):
    r = min(r, n-r)
    numer = reduce(operator.mul, range(n, n-r, -1), 1)
    denom = reduce(operator.mul, range(1, r+1), 1)
    return numer // denom

ans = 1
for c in Counter(factor).values():
	ans *= C(N+c-1, c)
	ans %= MOD

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter

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

factor=[]
for f in range(2, 1 + math.ceil(math.sqrt(M))):
	while M % f == 0:
		factor.append(f)
		M //= f

def F(n):
	if n == 1:
		return n
	return n * F(n-1)

def G(n, k):
	if k == 1:
		return n
	return n * G(n-1, k-1)

def H(n, k):
	return G(n+k-1, k) // F(k)

ans = 1
for c in Counter(factor).values():
	ans *= H(N, c)
	ans %= MOD

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter

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

factor=[]
for f in range(2, 1 + math.ceil(math.sqrt(M))):
	while M % f == 0:
		factor.append(f)
		M //= f

fac = math.factorial
def H(n, k):
	return fac(n+k-1) // fac(k) // fac(n-1)

ans = 1
for c in Counter(factor).values():
	ans *= H(N, c) % MOD
	ans %= MOD

print(ans)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce
def cb_count(n, r):
    X = 10**9+7
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def factorization(m):
    ans = {}
    p = 2
    while m>=p*p:
        if m%p==0:
            if not p in ans.keys():
                ans[p]=0
            ans[p]+=1
            m//=p
        else:
            p+=1
    if not m in ans.keys():
        ans[m]=0
    ans[m] += 1
    return ans
    #print()

n,m = list(map(int,input().split()))
# print(cb_count(n,m))
fct = factorization(m)
ans = 1
for p,q in fct.items():
    ans *= cb_count(n+q-1,n-1)

# print(fct)
print(ans%1000000007)

Submission status: Wrong Answer

Solution code:
def cb_count(n, r):
    X = 10**9+7
    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])%X
 
    return result%X
def factorization(m):
    ans = {}
    p = 2
    while m>=p*p:
        if m%p==0:
            if not p in ans.keys():
                ans[p]=0
            ans[p]+=1
            m//=p
        else:
            p+=1
    if not m in ans.keys():
        ans[m]=0
    ans[m] += 1
    return ans
    #print()

n,m = list(map(int,input().split()))
# print(cb_count(n,m))
fct = factorization(m)
ans = 1
for p,q in fct.items():
    ans *= cb_count(n+q-1,n-1)

# print(fct)
print(ans%1000000007)

Submission status: Wrong Answer

Solution code:
def cb_count(n, r):
    X = 10**9+7
    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])%X
 
    return result%X
def factorization(m):
    ans = {}
    p = 2
    while m>=p*p:
        if m%p==0:
            if not p in ans.keys():
                ans[p]=0
            ans[p]+=1
            m//=p
        else:
            p+=1
    if not m in ans.keys():
        ans[m]=0
    ans[m] += 1
    return ans
    #print()

n,m = list(map(int,input().split()))
# print(cb_count(n,m))
fct = factorization(m)
ans = 1
for p,q in fct.items():
    ans *= cb_count(n+q-1,q)

# print(fct)
print(ans%1000000007)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

def Pdeco(m):
    ret=[]
    for i in range(2,int((M)**(0.5))+1):
        if m<=i:
            if m!=1: ret.append(int(m))
            break
        elif i==int((M)**(0.5)):
            ret.append(m)
            break

        while m%i==0:
            m=m//i
            ret.append(i)
    return ret


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

L=Pdeco(M)
nums=set(L)

for n in nums:
    p=L.count(n)
    ans=(ans*cmb(N+p-1,N-1))%P

print(ans)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

def Pdeco(m):
    ret=[]
    for i in range(2,int((m)**(0.5))+1):
        if m<=i:
            if m!=1: ret.append(int(m))
            break
        elif i==int((m)**(0.5)):
            ret.append(m)
            break

        while m%i==0:
            m=m//i
            ret.append(i)
    return ret


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

L=Pdeco(M)
nums=set(L)

for n in nums:
    p=L.count(n)
    ans=(ans*cmb(N+p-1,N-1))%P

print(ans)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import collections
import math

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


import math
import random


class Prime:
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def is_prime(self, n):
        """
        prime test (hybrid)

        see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

        :param n:
        :return: boolean
        """
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        return True

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

        d = n - 1
        while d & 1 == 0:
            d >>= 1

        # use one of these lines / upper is more efficient.
        witnesses = self.get_witnesses(n)
        # witnesses = [random.randint(1, n - 1) for _ in range(100)]

        for w in witnesses:
            y = pow(w, d, n)

            while d != n - 1 and y != 1 and y != n - 1:
                y = (y * y) % n
                d <<= 1

            if y != n - 1 and d & 1 == 0:
                return False

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes


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


prime = Prime()
factors_counter = prime.find_factors(M)

result = 1
for k, v in factors_counter.items():
    result *= (int(math.factorial(v + (N - 1)) / int(math.factorial(v) * math.factorial(N - 1)))) % ((10**9) + 7)

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

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

MOD = 10 ** 9 + 7

def get_soinnsuu(num):
    soinnsuu = []
    for i in range(2, int(num ** 0.5) + 2):
        now_time = 0
        if num < i:
            break
        while num % i == 0:
            now_time += 1
            num = num // i
        if now_time > 0:
            soinnsuu.append(now_time)
    return soinnsuu


def comb(n, k):
    if k > n:
        return 0
    ret = 1
    k = min(k, n - k)
    for i in range(k):
        ret *= n - i
        ret //= i + 1
    return ret


def start_process(N, M):
    soinnsuu = get_soinnsuu(M)
    ans = 1
    for ele in soinnsuu:
        ans *= int(comb(ele + N - 1, ele))
    # print(soinnsuu)
    print(ans % MOD)


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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

MOD = 10 ** 9 + 7

def get_soinnsuu(num):
    soinnsuu = []
    for i in range(2, int(num ** 0.5) + 2):
        now_time = 0
        if num < i:
            break
        while num % i == 0:
            now_time += 1
            num = num // i
        if now_time > 0:
            soinnsuu.append(now_time)
    return soinnsuu


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


def start_process(N, M):
    soinnsuu = get_soinnsuu(M)
    ans = 1
    for ele in soinnsuu:
        ans *= int(comb(ele + N - 1, ele))
    # print(soinnsuu)
    print(ans % MOD)


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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
	li=inputList()
	n=li[0]
	m=li[1]

	if(m==1 or n==1):
		print(1)
		return

	prime={}

	make_prime(prime,m)

	ans=1
	for key in prime.keys():
		ans*=combination(n-1+prime[key],int(prime[key]))
		ans%=10**9+7
		ans=int(ans)

	print(ans)

def combination(num1,num2):
	ans=1
	for i in range(num2):
		ans*=num1-i
		ans/=i+1
		ans=int(ans)
	
	return int(ans)

def make_prime(prime,m):
	if(m==1):
		return prime;
	
	ans=1
	for i in range(2,m+1):
		if(m%i==0):
			ans=i
			break
	m/=ans
	if(ans in prime.keys()):
		prime[ans]+=1
	else:
		prime[ans]=1
	
	return make_prime(prime,int(m))

def inputList():
	a=list(map(int,input().split()))
	return a

def multisort(li,index):
	return sorted(li,key=lambda x: x[index])

if(__name__=='__main__'):
	main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
	li=inputList()
	n=li[0]
	m=li[1]

	prime={}

	make_prime(prime,m)

	ans=1
	for key in prime.keys():
		ans*=combination(n-1+prime[key],prime[key])
		ans%=10**9+7
		ans=int(ans)

	print(ans)

def combination(num1,num2):
	ans=1
	for i in range(num2):
		ans*=num1-i
		ans/=i+1
	
	return ans

def make_prime(prime,m):
	if(m==1):
		return prime;
	
	ans=1
	for i in range(2,m+1):
		if(m%i==0):
			ans=i
			break
	m/=ans
	if(ans in prime.keys()):
		prime[ans]+=1
	else:
		prime[ans]=1
	
	return make_prime(prime,int(m))

def inputList():
	a=list(map(int,input().split()))
	return a

def multisort(li,index):
	return sorted(li,key=lambda x: x[index])

if(__name__=='__main__'):
	main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
	li=inputList()
	n=li[0]
	m=li[1]

	prime={}

	make_prime(prime,m)

	ans=1
	for key in prime.keys():
		ans*=combination(n-1+prime[key],prime[key])
		ans%=10**9+7
		ans=int(ans)

	print(ans)

def combination(num1,num2):
	print(str(num1)+','+str(num2))
	ans=1
	for i in range(num2):
		ans*=num1-i
		ans/=i+1
	
	return ans

def make_prime(prime,m):
	if(m==1):
		return prime;
	
	ans=1
	for i in range(2,m+1):
		if(m%i==0):
			ans=i
			break
	m/=ans
	if(ans in prime.keys()):
		prime[ans]+=1
	else:
		prime[ans]=1
	
	return make_prime(prime,int(m))

def inputList():
	a=list(map(int,input().split()))
	return a

def multisort(li,index):
	return sorted(li,key=lambda x: x[index])

if(__name__=='__main__'):
	main()

Submission status: Wrong Answer

Solution code:
from math import factorial, sqrt
N,M=map(int,input().split())
prms={}
tmp=M
for i in range(2, int(sqrt(M))+2):
    while not tmp%i:
        if not i in prms:
            prms[i]=1
        else:
            prms[i]+=1
        tmp //= i
if tmp != 1:
    prms[tmp] = 1

print(prms)

res=1
def cmb(a,b):
    res=1
    if a - b < b:
        b = a-b
    for i in range(b):
        res *= (a-i)
        res //= (i+1)
    return res

for p, cnt in prms.items():
    res *= cmb(cnt+N-1, cnt)
    res %= 1000000007

print(res % 1000000007)

Submission status: Wrong Answer

Solution code:
from math import factorial, sqrt
N,M=map(int,input().split())
prms={}
tmp=M
for i in range(2, int(sqrt(M))+2):
    while not tmp%i:
        if not i in prms:
            prms[i]=1
        else:
            prms[i]+=1
        tmp //= i

if len(prms) == 0:
    prms[N] = 1

res=1
def cmb(a,b):
    res=1
    if a - b < b:
        b = a-b
    for i in range(b):
        res *= (a-i)
        res //= (i+1)
    return res

for p, cnt in prms.items():
    res *= cmb(cnt+N-1, cnt)
    res %= 1000000007

print(res % 1000000007)

Submission status: Wrong Answer

Solution code:
from math import factorial, sqrt
N,M=map(int,input().split())
prms={}
tmp=M
for i in range(2, int(sqrt(M))+2):
    while not tmp%i:
        if not i in prms:
            prms[i]=1
        else:
            prms[i]+=1
        tmp //= i

res=1
def cmb(a,b):
    res=1
    if a - b < b:
        b = a-b
    for i in range(b):
        res *= (a-i)
        res //= (i+1)
    return res

for p, cnt in prms.items():
    res *= cmb(cnt+N-1, cnt)
    res %= 1000000007

print(res % 1000000007)

Submission status: Wrong Answer

Solution code:
def factorize(m):
    # m:int (m>1)
    _l = [m] + list(range(int(m**0.5), 1, -1))
    factors={}
    while _l:
        p = _l[-1]
        _l = _l[:-1]
        if m%p==0:
            while m%p==0:
                factors[p] = factors.get(p,0)+1
                m=m//p
            while any([n%p==0 for n in _l]):
                _l=[n//p if n%p==0 else n for n in _l]
                _l=[n for n in _l if n!=1]      
    return factors


def devide_mod(n,mod):
    # only if mod is prime
    return power_mod(n,mod-2,mod)

def power_mod(n,m,mod):
    if m==0:
        return 1
    if m==1:
        return n%mod
    else:
        return (power_mod(n,m//2, mod)**2) * (n**(m%2)) %mod

N, M = list(map(int, input().split()))
mod=int(1e9+7)

memo={}
def combi(N, n):
    # (N-1+n)C(n)
    if n in memo:
        return memo[n]
    else:
        answer = 1
        for i in range(N, N+n):
            answer = answer * i %mod
        for i in range(1, n+1):
            answer = answer * devide_mod(i,mod) %mod
    return answer

answer = 1
factors = factorize(M)
for k,v in factors.items():
    answer = answer * combi(N,v)

print(answer)

Submission status: Wrong Answer

Solution code:
import math
def soinsu(N):
    sqr = int(math.sqrt(N))
    lis = []
    for i in range(2,sqr+2):
        while N % i == 0:
            lis.append(i)
            N = N // i
    if not lis:
        lis.append(N)
    return lis
mod = 1000000007
def modpow(a,b,MOD=mod):
    res = 1
    while b > 0:
        if (b & 1) == 1:
            res = (res*a) % MOD
        a = (a*a) % MOD
        b = b >> 1
    return res
fact = []
def ncrinit(MOD=mod):
    fact.append(1)
    for i in range(1,110005):
        fact.append((fact[i-1]*i)%MOD)

def calcnCr(n,r,MOD=mod):
    up = fact[n]
    down = modpow((fact[n-r]*fact[r])%mod,mod-2,mod)
    return (up*down)%mod

def compres(lis):
    li = []
    se = set(lis)
    for i in se:
        li.append(lis.count(i))
    return li
res = 1
N,M = list(map(int,input().split()))
ncrinit()
co = compres(soinsu(M))
for i in co:
    res = (res* (calcnCr(i+N-1,i)))%mod
print(res)

Submission status: Wrong Answer

Solution code:
import math
def soinsu(N):
    sqr = int(math.sqrt(N))
    lis = []
    for i in range(2,sqr+2):
        while N % i == 0:
            lis.append(i)
            N = N // i
    return lis
mod = 1000000007
def modpow(a,b,MOD=mod):
    res = 1
    while b > 0:
        if (b & 1) == 1:
            res = (res*a) % MOD
        a = (a*a) % MOD
        b = b >> 1
    return res
fact = []
def ncrinit(MOD=mod):
    fact.append(1)
    for i in range(1,110005):
        fact.append((fact[i-1]*i)%MOD)

def calcnCr(n,r,MOD=mod):
    up = fact[n]
    down = modpow((fact[n-r]*fact[r])%mod,mod-2,mod)
    return (up*down)%mod

def compres(lis):
    li = []
    se = set(lis)
    for i in se:
        li.append(lis.count(i))
    return li
res = 1
N,M = list(map(int,input().split()))
ncrinit()
co = compres(soinsu(M))
for i in co:
    res = (res* (calcnCr(i+N-1,i)))%mod
print(res)

Submission status: Wrong Answer

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

MOD = 10 ** 9 + 7

d = []

for i in range(2, int(math.sqrt(M))+2):
    if M % i == 0:
        d.append(0)
    while M % i == 0:
        d[-1] += 1
        M //= i

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

answer = 1
for i in d:
    answer *= comb(i+N-1, i)
    answer %= MOD

print(answer)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

# 素因数分解して、重複組み合わせを数える。
n,m = map(int,input().split())
MOD = 10**9+7

# 素因数分解
def factorize(n):
    fct = [] # Prime Factor
    b, e = 2, 0
    while b**2 <= n:
        while n % b == 0:
            n //= 2
            e += 1
        if e > 0:
            fct.append((b,e))
        b, e = b+1, 0
    if n>1:
        fct.append((n,1))
    return fct

# 組み合わせ計算(nCr)
def nCr(n,r):
    r = min(r,n-r)
    if r == 0:
        return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul,range(1,r+1))
    return over // under

f = factorize(m)
ans=1
for p,num in f:
    ans*=nCr(n+num-1,num)
    ans%=MOD

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
from math import sqrt
def nCr(n,r):
    return factorial(n)//(factorial(r)*factorial(n-r))

def factorize(p):
    b=[]

    for i in range(2,int(sqrt(p)+2)):
        a=0
        while((p%i)==0):
            a+=1
            p=p//i
          
        if a!=0:
            b.append(a)
        if p==1:
          break
    return b

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

sum=1
B=factorize(M)
for b in B:
    sum*=nCr(N-1+b,N-1)
    sum%=INF
print(sum)

Submission status: Wrong Answer

Solution code:
from math import factorial
from math import sqrt
def nCr(n,r):
    return factorial(n)//(factorial(r)*factorial(n-r))

def factorize(p):
    b=[]

    for i in range(2,int(sqrt(p)+2)):
        a=0
        while((p%i)==0):
            a+=1
            p=p//i
        if a!=0:
            b.append(a)
    return b

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

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

sum=1
B=factorize(M)
for b in B:
    sum*=nCr(N-1+b,N-1)
    sum%=INF
print(sum)

Submission status: Wrong Answer

Solution code:
from math import factorial
from math import sqrt
def nCr(n,r):
    return factorial(n)//(factorial(r)*factorial(n-r))

def factorize(p):
    b=[]

    for i in range(2,int(sqrt(p)+2)):
        a=0
        while((p%i)==0):
            a+=1
            p=p//i
        if a!=0:
            b.append(a)
    return b

INF=10**9+7
N,M=map(int,input().split())
sum=1
B=factorize(M)
for b in B:
    sum*=nCr(N-1+b,N-1)
    sum%=INF
print(sum)

Submission status: Wrong Answer

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

def factorize(n):
  prime_list = []
  factorize_list = []
  i = 2
  while i <= n:
    for p in prime_list:
      if i % p == 0:
        break
    else:
      prime_list.append(i)
      k = 0
      while n % i == 0:
        n //= i
        k += 1
      factorize_list.append(k)
  return(factorize_list)

ans = 1
for k in factorize(M):
  h = 1
  L = k + N
  k = min(k,N)
  for j in range(k):
    h *= L-j
  for j in range(k):
    h //= j+1
  h //= MOD
  ans *= h
  ans //= MOD

print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
import math
import collections
def tds(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
c=tds(m)
ans=1
for ci in c.values():
    ans*=math.factorial(n-1+ci)/math.factorial(n-1)/math.factorial(ci)
print(int(ans)%(10**9+7))

Submission status: Wrong Answer

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

P = 10**9+7
def get_soinsu(M):
    for i in range(2,1+int(M**0.5)):
        if M%i == 0:
            return [i] + get_soinsu(M//i)
    else:
        return [M]

soinsu = {}
for n in get_soinsu(M):
    soinsu[n] = 1 + soinsu.get(n,0)

def combi(n,r):
    tmp1,tmp2 = (1,1)
    for i in range(n-r+1,n+1):
        tmp1 *= i
    for i in range(2,r+1):
        tmp2 *= i
    return (tmp1//tmp2)%P

out = 1
for n in soinsu.values():
    out *= combi(N-1+n,n)
    out %= P
print(out)

Submission status: Wrong Answer

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

def prime(n):#素数かどうか＿素数なら1、そうでないなら0
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

#def prime_l(n):
#    for i in range(2,n+1):
#        if prime(i)==1:
#            yield i
#def prime_l(n):#n以下の素数のリスト
#    l=[1 for i in range(2,n+1)]#2からnの、n-1個 インデは-2
#    for i in range(n-1):#0からn-2 上記−２=インデ
#        if prime(i+2):
#            for j in range(2,n//(i+2)+1):#何倍のが0になるか
#                l[(i+2)*j-2]=0
#    return l

def prime_l(n):
    l=[1 for i in range(2,n+1)]#2からn インデは-2
    #sq_n=n**(1/2)
    for i in range(n-1):
        if l[i]==1:
            for j in range(2*(i+2),n+1,i+2):
                l[j-2]=0
    l1=[]
    for i in range(n-1):
        if l[i]==1:
            l1.append(i+2)
    return l1


def modpow(a,n,p):#a^n mod p
    res=1
    while n>0:
        if n&1:#１とのビット論理積が１、つまり奇数
            res=res*a%p
        a=a*a%p
        n>>=1
        #ビットの右シフト_2進数表記のnを小数点を固定して右に１桁ずらす_１桁小さくなる
    return res

if m==1:
    print(1)
else:
    #l=[i+2 for i in prime_l(int(1e9))]
    #l=prime_l(int(m**(1/2))) if m>=4 else prime_l(m)
    l=prime_l(int(m**(1/2)))#√までにしておくと、1にならずに残ったものは素数
    #ll=next(l)
    i=0
    d={}
    while m!=1 and i!=len(l)-1:
        if m%(l[i])==0:
            d[l[i]]=1
            m/=l[i]
            while m%(l[i])==0:
                d[l[i]]+=1
                m/=l[i]
        #ll=next(l)
        i+=1
        #while l[i]==0:
        #    i+=1
    if m!=1:
        d[m]=1
    #s_k=0
    #for i in d.values():
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    #for i in range(n+d_max-1):# 1!,2!,,,,(n+d_max-1)!
    #    n_fac*=i+1
    for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!
        n_fac*=i+1
        n_fac=n_fac%mod
        fac_l.append(n_fac)

    fac_1_l=[]
    for i in range(n+d_max):
        fac_1_l.append(modpow(fac_l[i],mod-2,mod))
    w=1
    for dv in d.values():
        w*=fac_l[n+dv-1]
        w=w%mod
        #n_n_fac=fac_l[n-dv]
        #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))
        #print(div)
        #if div>w:
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())


from collections import Counter
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return fct
if a==1 and b==1:
    print(1)
    exit()
elif len(factorize(b))<a:
    print(0)
    exit()
mod=10**9+7
print(reduce(mul,map(lambda x:cmb(a-1+x,a-1),Counter(factorize(b)).values()))%mod)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
def div(x,y):
    if x%y!=0:
        return 0
    else:
        return 1+div(int(x/y),y)

p=[]

def fact(s):
    if len(p)!=0:
        k=p[-1]
    else:
        k=2
    for i in range(2,max(int(s**0.5) +2,2)):
        a=div(s,i)
        if a==0:
            0
        else:
            p.append(a)
            s=int(s/i**a)
            
fact(m)
def comb(nn,rr):
    rr=min(rr,nn-rr)
    rt=1
    for i in range(rr):
        #rt=rt*(nn-i)/(rr-i)
        rt*=(nn-i)
    for i in range(rr):
        rt//=(rr-i)
    return int(rt)

mo=10**9 +7
ans=1
if len(p)==0:
    ans=1
else:
    for i in p:
        ans*=comb(i+n-1, i) % mo
print(ans % mo)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
def div(x,y):
    if x%y!=0:
        return 0
    else:
        return 1+div(int(x/y),y)

p=[]

def fact(s):
    if len(p)!=0:
        k=p[-1]
    else:
        k=2
    for i in range(2,max(int(s**0.5) +2,2)):
        a=div(s,i)
        if a==0:
            0
        else:
            p.append(a)
            s=int(s/i**a)
            
fact(m)
def comb(nn,rr):
    rr=min(rr,nn-rr)
    rt=1
    for i in range(rr):
        #rt=rt*(nn-i)/(rr-i)
        rt*=(nn-i)
    for i in range(rr):
        rt//=(rr-i)
    return int(rt)
print(p)
mo=10**9 +7
ans=1
if len(p)==0:
    ans=1
else:
    for i in p:
        ans*=comb(i+n-1, i) % mo
        print(ans,comb(i+n-1, i),mo)
print(ans % mo)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
def div(x,y):
    if x%y!=0:
        return 0
    else:
        return 1+div(int(x/y),y)

p=[]

def fact(s):
    if len(p)!=0:
        k=p[-1]
    else:
        k=2
    for i in range(2,max(int(s**0.5) +2,2)):
        a=div(s,i)
        if a==0:
            0
        else:
            p.append(a)
            s=int(s/i**a)
            
fact(m)
def comb(nn,rr):
    rr=min(rr,nn-rr)
    rt=1
    for i in range(rr):
        rt=rt*(nn-i)/(rr-i)
    return int(rt)
#print(p)
mo=10**9+7
ans=1
if len(p)==0:
    ans=1
else:
    for i in p:
        ans=(ans*comb(i+n-1, i)) % mo
        #print(ans,comb(i+n-1, i, exact=True))
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
import math
a=[]
ans=1
def calc(n):#nの素因数分解
    for i in range(2,int(n**0.5)+10):
        count=0
        while n%i==0:
            n//=i
            count+=1
        if count>=1:
            a.append([i,count])
def conb(n,k):
    return math.factorial(n)//(math.factorial(n-k)*math.factorial(k))
calc(M)
for i in range(len(a)):
    ans*=conb(a[i][1]+N-1,a[i][1])
print(ans%(10**9+7))