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:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int


def prime_table(n):
    rn = int(ceil(sqrt(n)))
    t = [True] * (rn + 1)
    t[0] = False
    t[1] = False

    i = 2
    while i * i <= n:
        for ii in range(2 * i, rn + 1, i):
            t[ii] = False
        i += 1
    return [x for x, i in enumerate(t) if i == True]


def combination(n, m):
    return reduce(mul, range(n, n - m, -1), 1) // factorial(m)

def solve(N: int, M: int):
    fs = defaultdict(int)
    for p in prime_table(M):
        while (M % p) == 0:
            fs[p] += 1
            M //= p

    ret = 1
    for c in fs.values():
        ret *= combination(c + N - 1, c)

    return ret % MOD


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    result = solve(N, M)
    print(result)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int


def prime_table(n):
    rn = int(ceil(sqrt(n)))
    t = [True] * (rn + 1)
    t[0] = False
    t[1] = False

    i = 2
    while i * i <= n:
        for ii in range(2 * i, rn + 1, i):
            t[ii] = False
        i += 1
    return [x for x, i in enumerate(t) if i == True]


def permutation(n, m):
    return reduce(mul, range(n, n - m, -1), 1)

def combination(n, m):
    return permutation(n, m) // factorial(m)

def solve(N: int, M: int):
    fs = defaultdict(int)
    for p in prime_table(M):
        while (M % p) == 0:
            fs[p] += 1
            M //= p

    ret = 1
    for c in fs.values():
        ret *= combination(c + N - 1, c)

    return ret % MOD


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    result = solve(N, M)
    print(result)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a1, a2 = 2, M
a = {}
while (a1 - 1) ** 2 <= a2:
    if a2 % a1 == 0:
        a2 //= a1
        a[a1] = a.get(a1, 0) + 1
    else:
        a1 += 1
a[a2] = a.get(a2, 0) + 1
p = 1
for v in a.values():
    for i in range(v):
        p = p * (v + N - 1 - i) // (i + 1)
print(p % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
from math import factorial as f
N, M = map(int, input().split())
a1, a2 = 2, M
a = {}
while (a1 - 1) ** 2 <= a2 or a1 == a2:
    if a2 % a1 == 0:
        a2 //= a1
        if a1 in a:
            a[a1] += 1
        else:
            a[a1] = 1
    else:
        a1 += 1
p = 1
if a == {}:
    a = {M: 1}
for v in a.values():
    p *= f(v + N - 1) // (f(v) * f(N - 1))
print(p % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
from math import factorial as f
N, M = map(int, input().split())
a1, a2 = 2, M
a = {}
while a2 != 1 and ((a1 - 1) ** 2 <= a2 or a1 == a2):
    if a2 % a1 == 0:
        a2 //= a1
        if a1 in a:
            a[a1] += 1
        else:
            a[a1] = 1
    else:
        a1 += 1
p = 1
for v in a.values():
    p *= f(v + N - 1) // (f(v) * f(N - 1))
print(p % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
from collections import Counter
from math import factorial as f
N, M = map(int, input().split())
a1, a2 = 2, M
a = []
while a2 != 1 and ((a1 - 1) ** 2 <= a2 or a1 == a2):
    if a2 % a1 == 0:
        a.append(a1)
        a2 //= a1
    else:
        a1 += 1
ca = Counter(a)
p = 1
for v in ca.values():
    p *= f(v + N - 1) // (f(v) * f(N - 1))
print(p % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 14:59:02 2019

@author: Yamazaki Kenichi
"""

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

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, 10**6):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

P = [2]
for i in range(3,31624):
    flg = True
    for p in P:
        if i % p == 0:
            flg = False
            break
    if flg:
        P.append(i)

mp = [0 for i in range(len(P))]
for i in range(len(P)):
    while M % P[i] == 0:
        mp[i] += 1
        M //= P[i]
ans = 1
for c in mp:
    ans= (ans * cmb(N+c-1,c,10**9+7))%mod
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 14:59:02 2019

@author: Yamazaki Kenichi
"""

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

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, 10**5+100):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

P = [2]
for i in range(3,31624):
    flg = True
    for p in P:
        if i % p == 0:
            flg = False
            break
    if flg:
        P.append(i)

mp = [0 for i in range(len(P))]
for i in range(len(P)):
    while M % P[i] == 0:
        mp[i] += 1
        M //= P[i]
ans = 1
for c in mp:
    ans= (ans * cmb(N+c-1,c,10**9+7))%mod
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

import math
from operator import mul
from functools import reduce


inf = 10**9+7


# nCr
def combination(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


# nまでの素数を列挙する
class PrimeUtil:
    def __init__(self, n):
        self.l_is_prime = [True for _ in range(n+1)]
        self.l_is_prime[0] = False
        self.l_is_prime[1] = False
        self.n = n
        self.primes = []
        for k in range(2, n+1):
            if self.l_is_prime[k]:
                self.primes.append(k)
                self._set_false(k)

    # pの倍数全てのl_is_primeのフラグをFalseにする
    def _set_false(self, p):
        k = p
        for _ in range(1, self.n//p):
            k += p
            self.l_is_prime[k] = False

    # 素因数分解した結果を返す
    def factor(self, k):
        ret = {}
        tmp = k
        for p in self.primes:
            if p > tmp:
                break
            while True:
                if tmp % p != 0:
                    break
                ret.setdefault(p, 0)
                ret[p] += 1
                tmp /= p
                if tmp == 1:
                    break
        if tmp > 0:
            ret[tmp] = 1
        return ret


def main():
    N, M = list(map(int, input().split()))
    pu = PrimeUtil(100000)
    ans = 1
    f = pu.factor(M)
    for v in f.values():
        ans *= combination(v+N-1, v)
        ans %= inf
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

import math
from operator import mul
from functools import reduce


inf = 10**9+7


# nCr
def combination(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


# nまでの素数を列挙する
class PrimeUtil:
    def __init__(self, n):
        self.l_is_prime = [True for _ in range(n+1)]
        self.l_is_prime[0] = False
        self.l_is_prime[1] = False
        self.n = n
        self.primes = []
        for k in range(2, n+1):
            if self.l_is_prime[k]:
                self.primes.append(k)
                self._set_false(k)

    # pの倍数全てのl_is_primeのフラグをFalseにする
    def _set_false(self, p):
        k = p
        for _ in range(1, self.n//p):
            k += p
            self.l_is_prime[k] = False

    # 素因数分解した結果を返す
    def factor(self, k):
        ret = {}
        tmp = k
        for p in self.primes:
            if p > tmp:
                break
            while True:
                if tmp % p != 0:
                    break
                ret.setdefault(p, 0)
                ret[p] += 1
                tmp /= p
                if tmp == 1:
                    break
        return ret


def main():
    N, M = list(map(int, input().split()))
    pu = PrimeUtil(100000)
    ans = 1
    f = pu.factor(M)
    for v in f.values():
        ans *= combination(v+N-1, v)
        ans %= inf
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = [ int(it) for it in input().split() ]
MOD = 1000000007

import math
sM = int(math.sqrt(M)+1)

p_li = []
m = M
'''
for i in range(100000):
  for j in range(2,sM+1):
    if (m%j)==0:
      p_li.append(j)
      m//=j
      break
  if (m==1):
    break
'''

for i in range(2, sM + 1):
    if m % i == 0:
        ctr = 0
        while m % i == 0:
            m //= i
            ctr += 1
        p_li.append(ctr)
    if m == 1:
        break


'''
import collections
co = collections.Counter(p_li)
vec = co.values()
'''

vec = p_li

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def mod_inv2(a, m):
    return pow(a, m - 2, m)

s = 1
for v in vec:
  
  ss = 1
  for i in range(N-1+v,v,-1):
    ss = (ss*i)%MOD
  for i in range(N-1,0,-1):
    ss = (ss*mod_inv2(i,MOD))%MOD
  s *= (ss%MOD)
  s = s%MOD
print (s%MOD)

Submission status: Wrong Answer

Solution code:
N, M = [ int(it) for it in input().split() ]
MOD = 1000000007

import math
sM = int(math.sqrt(M)+1)

p_li = []
m = M
for i in range(sM):
  for j in range(2,sM+1):
    if (m%j)==0:
      p_li.append(j)
      m//=j
      break
  if (m==1):
    break
if (m!=1):
  p_li.append(m)
    
    
import collections
co = collections.Counter(p_li)
vec = co.values()

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

print (vec)  
  
s = 1
for v in vec:
  
  ss = 1
  for i in range(N-1+v,v,-1):
    ss = (ss*i)%MOD
  for i in range(N-1,0,-1):
    ss = (ss*mod_inv(i,MOD))%MOD
  s *= (ss%MOD)
  s = s%MOD
print (s%MOD)

Submission status: Wrong Answer

Solution code:
N, M = [ int(it) for it in input().split() ]
MOD = 1000000007

import math
sM = int(math.sqrt(M)+1)

p_li = []
m = M
for i in range(sM):
  for j in range(2,sM+1):
    if (m%j)==0:
      p_li.append(j)
      m//=j
      break
  if (m==1):
    break
    
import collections
co = collections.Counter(p_li)
vec = co.values()

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

s = 1
for v in vec:
  
  ss = 1
  for i in range(N-1+v,v,-1):
    ss = (ss*i)%MOD
  for i in range(N-1,0,-1):
    ss = (ss*mod_inv(i,MOD))%MOD
  s *= (ss%MOD)
  s = s%MOD
print (s%MOD)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from collections import Counter
import operator as op
from functools import reduce

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

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
        primfac.append(n)
    return primfac

ans = 1
divisors = primes(M)
for k, v in Counter(divisors).items():
    ans *= ncr(N - 1 + v, v)
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
import math
n,m=map(int,input().split())
flag=0
P=[]
p=m
while flag==0:
  cur=p
  for i in range(2,int(p**0.5)+1):
    if p%i==0:
      P.append(i)
      p//=i
      break
  if p==cur:
    P.append(p)
    flag=1
c=collections.Counter(P)
Primes=set(P)
def f(i):
  return math.factorial(i)
def fn(i):
  return f(n+i-1)//(f(n-1)*f(i))%(10**9+7)
ans=1
for p in Primes:
  ans*=fn(c[p])
  ans%=(10**9+7)
print(1 if m==0 else ans)

Submission status: Wrong Answer

Solution code:
def FACTOR(DICT, N):
    FACT = DICT
    LIM = int(N**0.5)+2
    for i in range(2, LIM):
        if N%i == 0:
            FACT[i] = 0
        while N%i == 0:
            FACT[i] += 1
            N //= i
    if len(FACT) == len(DICT):
        if N != 1:
            FACT[N] = 1
        return FACT
    return FACTOR(FACT, N)

def comb_rep(n, r):
    N = n+r-1
    ANS = 1
    for R in range(r):
        ANS *= N-R
        ANS /= R+1
        ANS %= 10**9+7
    return int(ANS)

MOD = 10**9+7
n, m = map(int, input().split())
factor = FACTOR({}, m)
ans = 1
for i in factor:
    ans *= comb_rep(n, factor[i])
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
def FACTOR(DICT, N):
    FACT = DICT
    LIM = int(N**0.5)+2
    for i in range(2, LIM):
        if N%i == 0:
            FACT[i] = 0
        while N%i == 0:
            FACT[i] += 1
            N //= i
    if len(FACT) == len(DICT):
        if N != 1:
            FACT[N] = 1
        return FACT
    return FACTOR(FACT, N)

def comb_rep(n, r):
    N = n+r-1
    ANS = 1
    for R in range(r):
        ANS *= N-R
        ANS /= R+1
    return int(ANS)

MOD = 10**9+7
n, m = map(int, input().split())
factor = FACTOR({}, m)
ans = 1
for i in factor:
    ans *= comb_rep(n, factor[i])
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
def FACTOR(DICT, N):
    FACT = DICT
    LIM = int(N**0.5)+2
    for i in range(2, LIM):
        if N%i == 0:
            FACT[i] = 0
        while N%i == 0:
            FACT[i] += 1
            N //= i
    if len(FACT) == len(DICT):
        if N != 1:
            FACT[N] = 1
        return FACT
    return FACTOR(FACT, N)

def comb_rep(n, r):
    N = n+r-1
    ANS = 1
    for R in range(r):
        ANS *= N-R
        ANS /= R+1
    return int(ANS)

MOD = 10**9+7
n, m = map(int, input().split())
factor = FACTOR({}, m)
ans = 1
for i in factor:
    ans *= comb_rep(n, factor[i])
    ans %= MOD
    print(i, comb_rep(n, factor[i]))
print(factor, ans)

Submission status: Wrong Answer

Solution code:
def FACT(DICT, N):
    FACT = DICT
    LIM = int((N**0.5)//1)+1
    for i in range(2, LIM):
        if N%i == 0:
            FACT[i] = 0
        while N%i == 0:
            FACT[i] += 1
            N //= i
        if len(FACT) == len(DICT):
            FACT[N] = 1
            return FACT
    return FACT(FACT, N)

def comb_rep(n, r):
    N = n+r-1
    ANS = 1
    for R in range(r):
        ANS *= N-R
        ANS /= R+1
    return int(ANS)

MOD = 10**9+7
n, m = map(int, input().split())
if m == 1:
    print(1)
    exit()
factor = FACT({}, m)
ans = 1
for i in factor:
    ans *= comb_rep(n, factor[i])
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
import math
n,m=map(int,input().split())
flag=0
P=[]
p=m
while flag==0:
  cur=p
  for i in range(2,int(p**0.5)+1):
    if p%i==0:
      P.append(i)
      p//=i
      break
  if p==cur:
    P.append(p)
    flag=1
c=collections.Counter(P)
Primes=set(P)
def f(i):
  return math.factorial(i)
def fn(i):
  return f(n+i-1)//(f(n-1)*f(i))%(10**9+7)
ans=1
for p in Primes:
  ans*=fn(c[p])
  ans%=(10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
import math
n,m=map(int,input().split())
flag=0
P=[]
p=m
while flag==0:
  cur=p
  for i in range(2,int(p**0.5)+1):
    if p%i==0:
      P.append(i)
      p//=i
      break
  if p==cur:
    P.append(p)
    flag=1
c=collections.Counter(P)
Primes=set(P)
def f(i):
  return math.factorial(i)
def fn(i):
  return f(n+i-1)//(f(n-1)*f(i))
ans=1
for p in Primes:
  ans*=fn(c[p])%(10*9+7)
print(ans%(10*9+7))

Submission status: Wrong Answer

Solution code:
import collections
import math
n,m=map(int,input().split())
flag=0
P=[]
p=m
while flag==0:
  cur=p
  for i in range(2,int(p**0.5)+1):
    if p%i==0:
      P.append(i)
      p//=i
      break
  if p==cur:
    P.append(p)
    flag=1
c=collections.Counter(P)
Primes=set(P)
def f(i):
  return math.factorial(i)
def fn(i):
  return f(n+i-1)//(f(n-1)*f(i))
ans=1
for p in Primes:
  ans*=fn(c[p])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return sorted(divisors,reverse=True)

# 重複順列
def count(nlist):
    nset = list(set(nlist))
    denom = 1
    for n in nset:
        cnt = nlist.count(n)
        prod = 1
        for i in range(1,cnt+1):
            prod *= i
        denom *= prod
    anom = 1
    for i in range(1,len(nlist)+1):
        anom *= i
    return(anom//denom)



# 大きい順に約数を並べて、dfsでなんとかならないか。
divs = make_divisors(M)
divdict = {str(div):i for i, div in enumerate(divs)} #要素に対応させる
divlist = [] #約数リスト
stack = deque([])
# 約数リスト0のところを追加しておこう
for div in divs:
    stack.append([div,M//div])

ans = 0
if N == 2:
    for div in divs:
        if div < M//div:
            ans += 2
        elif div == M//div:
            ans += 1
else:
    # 既出セット
    while len(stack) > 0:
        nlist = stack.pop()
        div = nlist[-2]
        divided = nlist[-1]
        # 割った数よりは小さい値で割っていく
        ind = divdict[str(div)]
        for div in divs[ind:]:
            if len(nlist) < N and divided%div == 0:
                new = nlist[:-1]+[div, divided//div]
                stack.append(new)
                # 指定まで溜まったら
                if len(new) == N:
                    prod = nlist[0]
                    for i in range(1,N):
                        prod *= new[i]
                    if new[-1] <= new[-2] and prod==M: #順序保証と積の保証
                        ans += count(new)


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

Submission status: Wrong Answer

Solution code:
from math import factorial

N,M=map(int,input().split())
MOD=(10**9)+7
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(n**0.5) + 2
    for num in range(2,tmp):
        count=0
        while n % num == 0:
            n //= num
            count+=1
        if count>0:
          factor.append(count)
    #リストが空ならそれは素数
    if not factor:
        return [1]
    elif n!=1:
        factor.append(1)
        return factor
    else:
        return factor


factor=trial_division(M)

ans=1
for a in factor:
  for i in range(a):
    ans*=N+i
  ans //= factorial(a)
  ans%=MOD

print(ans)

Submission status: Wrong Answer

Solution code:
import math

N,M=map(int,input().split())
MOD=(10**9)+7
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 2
    for num in range(2,tmp):
        count=0
        while n % num == 0:
            n //= num
            count+=1
        if count>0:
          factor.append(count)
    #リストが空ならそれは素数
    if not factor:
        return [1]
    elif n!=1:
        factor.append(1)
        return factor
    else:
        return factor
      
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


factor=trial_division(M)

ans=1
for a in factor:
  ans*=combinations_count(a+N-1,a)
  ans%=MOD
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

if M==1:
  print(1)
  exit()
MOD=10**9+7
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 2
    for num in range(2,tmp):
        count=0
        while n % num == 0:
            n //= num
            count+=1
        if count>0:
          factor.append(count)
    #リストが空ならそれは素数
    if not factor:
        return [1]
    else:
        return factor
      
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


factor=trial_division(M)

ans=1
for a in factor:
  ans*=combinations_count(a+N-1,a)
  ans%=MOD
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import itertools

N,M=map(int,input().split())
MOD=10**9+7
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 2
    for num in range(2,tmp):
        count=0
        while n % num == 0:
            n //= num
            count+=1
        if count>0:
          factor.append(count)
    #リストが空ならそれは素数
    if not factor:
        return [1]
    else:
        return factor
      
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


factor=trial_division(M)

ans=1
for a in factor:
  ans*=combinations_count(a+N-1,a)
  ans%=MOD
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import itertools

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

def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 2
    for num in range(2,tmp):
        count=0
        while n % num == 0:
            n //= num
            count+=1
        if count>0:
          factor.append(count)
    #リストが空ならそれは素数
    if not factor:
        return [1]
    else:
        return factor
      
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


factor=trial_division(M)

ans=1
for a in factor:
  ans*=combinations_count(a+N-1,a)
print(ans)

Submission status: Wrong Answer

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

L=[0 for i in range((10**5)+1)]
for i in range(2,10**5):
    while M%i==0:
        L[i]+=1
        M//=i
    if M==1:
        break
if M>1:
    L.append(1)
    
mod=(10**9+7)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N1 = (10**5)*2
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N1 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans=1
for i in range(len(L)):
    if L[i]!=0:
        ans*=cmb(L[i]+N-1,min(L[i],N),mod)
        ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter


#  [(要素, 出現回数), (要素, 出現回数)]というようなタプルのリストを作成する
def counter(array):
    return list(Counter(array).most_common())


# combを実装する
def comb_cal(n, r):
    tmp = 1
    for i in range(r):
        tmp *= (n - i)
    for i in range(r):
        tmp //= r - i
    return tmp


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

frac = []

# 約数の列挙
while True:
    for i in range(2, int(M**(1/2))+1):
        if M % i == 0:  # 割り切れるかどうか
            frac.append(i)  # 配列に代入する
            M //= i  # 値で割る
            break  # 値を一回入れたらまたWhileに戻る
    break
if M > 1:
    frac.append(M)

c = counter(frac)

ans = 1
for x in c:
    ans *= (comb_cal(x[1] + N-1, x[1]) % MOD)
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
from math import *


def soin(num):
    re = []
    div = 2
    while 1:
        lim = int(num ** 0.5) + 1
        while num % div:
            div += 1
            if div > lim:
                re += [1]
                return re
        sisu = 0
        while num % div == 0:
            num //= div
            sisu += 1
        re += [sisu]
        if num == 1:
            return re


def com(a, b):
    if a == b:
        return 1
    t = (a, b)
    if (a, b) in com_memo:
        return com_memo[t]
    re = com(a - 1, b) * a // (a - b)
    com_memo[t] = re
    return re


def f(n, m):
    sisus = soin(m)
    ans = 1
    for s in sisus:
        ans = ans * com(s + n - 1, n - 1) % md
    print(ans)


md = 10 ** 9 + 7
n, m = map(int, input().split())
com_memo = {}
f(n, m)

Submission status: Wrong Answer

Solution code:
from math import *


def soin(num):
    re = []
    div = 2
    while 1:
        lim = int(num ** 0.5) + 1
        while num % div:
            div += 1
            if div > lim:
                re += [1]
                return re
        sisu = 0
        while num % div == 0:
            num //= div
            sisu += 1
        re += [sisu]
        if num == 1:
            return re


def com(a, b):
    t = (a, b)
    if (a, b) in com_memo:
        return com_memo[t]
    re = factorial(a) // factorial(b) // factorial(a - b) % md
    com_memo[t] = re
    return re


def f(n, m):
    sisus = soin(m)
    ans = 1
    for s in sisus:
        ans = ans * com(s + n - 1, n - 1) % md
    print(ans)


md = 10 ** 9 + 7
n, m = map(int, input().split())
com_memo = {}
f(n, m)

Submission status: Wrong Answer

Solution code:
from math import *


def soin(num):
    re = []
    div = 2
    br = 0
    while 1:
        lim = int(num ** 0.5) + 1
        while num % div:
            div += 1
            if div > lim:
                re += [1]
                br = 1
                break
        if br: break
        sisu = 0
        while num % div == 0:
            num //= div
            sisu += 1
        re += [sisu]
        if num == 1: break
    return re


def com(a, b):
    return factorial(a) // factorial(b) // factorial(a - b)


md = 10 ** 9 + 7
n, m = map(int, input().split())
sisus = soin(m)
ans = 1
for s in sisus:
    ans = ans * com(s + n - 1, n - 1) % md

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
import collections
from operator import mul
from functools import reduce
N, M = map(int, input().split())

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

ps = []
tmp = M
for m in range(2, int(M**0.5)+2):
    while tmp % m == 0:
        tmp /= m
        ps.append(m)
    if int(tmp) == 1:
        break
ps = collections.Counter(ps)

ans = 1
mod = 10**9+7
for c in ps.values():
    ans *= cmb(c+N-1, c) % mod
    if ans > mod:
        ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
import collections
from operator import mul
from functools import reduce
N, M = map(int, input().split())


def cmb(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

ps = []
tmp = M
for m in range(2, int(M**0.5)+2):
    while tmp % m == 0:
        tmp /= m
        ps.append(m)
    if int(tmp) == 1:
        break
ps = collections.Counter(ps)

ans = 1
mod = 10**9+7
for c in ps.values():
    ans *= cmb(c+N-1, c)
    if ans > mod:
        ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
import collections
from operator import mul
from functools import reduce
N, M = map(int, input().split())


def cmb(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

ps = []
tmp = M
for m in range(2, int(M**0.5)+2):
    while tmp % m == 0:
        tmp /= m
        ps.append(m)
ps = collections.Counter(ps)

ans = 1
mod = 10**9+7
for c in ps.values():
    ans *= cmb(c+N-1, c)
    if ans > mod:
        ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]

def prime_decomposition(n):
  table = []
  i = 2
  while i * i <= n:
    count = 0
    while n % i == 0:
      n //= i
      count += 1
    if count != 0:
        table.append((i, count))
    i += 1
  if n > 1:
    table.append((n, 1))
  return table

def cmb(n,r):
    from operator import mul
    from functools import reduce
    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

mod = 10 ** 9 + 7
A = prime_decomposition(M)
print(A)
result = 1
for _, a in A:
    result = result * cmb(a + N - 1, a) % mod

print(result)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
n,m=map(int,input().split())
dic=dict()
p=2
while m>=p*p:
    if m%p==0:
        dic[p]=0
        while m%p==0:
            dic[p]+=1
            m//=p
    p+=1
if not m in dic.keys():
    dic[m]=0
dic[m]+=1
def comb(a,b):
    p=1
    for i in range(a,a-b,-1):
        p*=i
    for i in range(2,b+1):
        p//=i
    return p
l=[comb(i+n-1,i) if 1 not in dic.keys() else 1 for i in dic.values() ]
print(reduce(lambda x,y: x*y%1000000007, l))

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
sys.setrecursionlimit(1000000)
n,m=map(int,input().split())
dic=dict()
sqrm=int(m**0.5)
for i in range(2,sqrm+1):
    if m%i==0:dic[i]=0
    while m%i==0:
        dic[i]+=1
        m//=i
if m>=sqrm:dic[m]=1
ans=1
def comb(a,b):
    p=1
    for i in range(a,a-b,-1):
        p*=i
    for i in range(2,b+1):
        p//=i
    return p
l=[comb(i+n-1,i) if 1 not in dic.keys() else 1 for i in dic.values() ]
print(reduce(lambda x,y: x*y%1000000007, l))

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
sys.setrecursionlimit(1000000)
n,m=map(int,input().split())
dic=dict()
sqrm=int(m**0.5)
for i in range(2,sqrm+1):
    if m%i==0:dic[i]=0
    while m%i==0:
        dic[i]+=1
        m//=i
if m>=sqrm:dic[m]=1
ans=1
def comb(a,b):
    p=1
    for i in range(a,a-b,-1):
        p*=i
    for i in range(2,b+1):
        p//=i
    return p
l=[comb(i+n-1,i) for i in dic.values()]
print(reduce(lambda x,y: x*y%1000000007, l))