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):
n,m=map(int,input().split())

def prime(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1




#            yield i
#n以下の素数のリスト




#                l[(i+2)*j-2]=0


def prime_l(n):
    l=[1 for i in range(2,n+1)]
    #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
        
    return res

if m==1:
    print(1)
else:
    
    
    l=prime_l(int(m**(1/2)))
    #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
    
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    
    #    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-1):
        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)
        
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)


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

def prime(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1




#            yield i
#n以下の素数のリスト




#                l[(i+2)*j-2]=0


def prime_l(n):
    l=[1 for i in range(2,n+1)]
    #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
        
    return res

if m==1:
    print(1)
else:
    
    l=prime_l(int(m**(1/2))) if m>=4 else prime_l(m)
    #ll=next(l)
    i=0
    d={}
    while m!=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
    #s_k=0
    
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    
    #    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-1):
        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)
        
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)


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

def prime(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1




#            yield i
#n以下の素数のリスト




#                l[(i+2)*j-2]=0


def prime_l(n):
    l=[1 for i in range(2,n+1)]
    #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
        
    return res

if m==1:
    print(1)
else:
    
    
    l=prime_l(int(m**(1/2)))
    #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
    
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    
    #    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)
        
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)


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

def prime(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1




#            yield i
#n以下の素数のリスト




#                l[(i+2)*j-2]=0


def prime_l(n):
    l=[1 for i in range(2,n+1)]
    #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
        
    return res

if m==1:
    print(1)
else:
    
    l=prime_l(int(m**(1/2)))
    #ll=next(l)
    i=0
    d={}
    while m!=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
    #s_k=0
    
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    
    #    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-1):
        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)
        
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)


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

def prime(n):
    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

l=prime_l(int(1e9))
ll=next(l)
d={}
while m!=1:
    if m%ll==0:
        d[ll]=1
        m/=ll
        while m%ll==0:
            d[ll]+=1
            m/=ll
    ll=next(l)
#s_k=0

#    s_k+=i
for dk in d.keys():
    #print(dk)
    #print(d[dk])
    pass
n_fac=1
fac_l=[]
d_max=max(d.values())
for i in range(n+d_max):# 1!,2!,,,,
    n_fac*=i+1
    n_fac=int(n_fac%(1e9+7))
    fac_l.append(n_fac)

    print(fac_l[i])
w=1
for dv in d.values():
    w*=fac_l[n+dv-1-1]
    w=int(w%(1e9+7))
    #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)
print(w)


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

def prime(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1




#            yield i
#n以下の素数のリスト




#                l[(i+2)*j-2]=0


def prime_l(n):
    l=[1 for i in range(2,n+1)]
    #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
        
    return res

if m==1:
    print(1)
else:
    
    
    l=prime_l(int(m**(1/2)))
    #ll=next(l)
    i=0
    d={}
    while m!=1 and i!=len(l):
        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
    
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    
    #    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)
        
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted