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

Solution in C++14 (GCC 5.4.1) (judge verdict: Time Limit Exceeded)

#include<bits/stdc++.h>

using namespace std;

long long  n , m ;



long long a [ 1003 ] , res ,cntt,v[1003];

long long prime[10]={ 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 },cnt[10],xxxx[10]={4,3,2,1,1,1,1,1,1,1},cnttt[31][10];

int mmm[2177777];

inline long long C(long long x,long long y){

	if(y == 0)return 1ll;

	if(mmm[(x*1003+y)%2177777])return mmm[(x*1003+y)%2177777];
	
	long long ans2 = 1 , xx[ y ];
	for(long long i = 0 ;i < 10 ;i++)cnt[i]=cnttt[y][i];
	for(long long i=0;i<y;i++)xx[i]=x-i;
	for(long long i = 0 ;i < y;i++)

		for(long long xxx = 0;xxx < 10 ; xxx++)

			while(xx[ i ] % prime[ xxx ] == 0&&cnt[ xxx ])

				cnt[ xxx ]--,

				xx[ i ] /= prime[ xxx ];

	for(long long i = 0 ; i < y ;i++)ans2=(ans2 * xx[ i ])%1000000007;
	mmm[( x*1003+y )%2177777] = ans2;
	return ans2;

}

inline void dfs(long long x,long long y,long long z){

	if(x == 1){

		long long cnt = n,ans2 = 1;

		for(long long i = 0;i < cntt ;i++)
			ans2 = ans2 * C (cnt , a[i]) %1000000007,
			cnt -= a[i];

		res = (res + ans2)%1000000007;
		return;
	}

	if(y == n)return;

	for(long long i = 0;i < z&&v [ i ] <= x;i++)

		if(x % v [i] ==0)
			
			a[i]++,

			dfs(x/v[i],y + 1,i + 1),
			
			a[i]--;
}

int main(){
	cin>>n>>m;
	
	
	for(long long i=2;i<=sqrt(m);i++)

		if(!(m%i))

			if(double(i)!=double(sqrt(m)))

				v[cntt++]=m/i,

				v[cntt++]=i;

			else

				v[cntt++]=i;
	
	for(int y=1;y<31;y++)
		for(int i=0;i<10;i++)
		{
			int ppp=1;
			for(int j=0;j<xxxx[i];j++)
				ppp*=prime[i],
				cnttt[y][i]+=y/ppp; 
		}
	sort(v,v+cntt);

	v[cntt++]=m;

	dfs(m,0,cntt);

	cout<<res;

}