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# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
namespace kozaiyApp
{
    public class Factorization
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int restM = M;
            long ans = 1;

            // 素因数分解
            for (int i = 2; i * i <= restM; i++)
            {
                if (restM % i == 0)
                {
                    int cnt = 0; // cntは2^Xとか3^XとかのXの部分　何乗か
                    while (restM % i == 0)
                    {
                        cnt++;
                        restM /= i;
                    }
                    ans *= calcComb(cnt + N - 1, N - 1); // N-1はcntと同じ
                    ans %= mod;
                }
            }

            // 最後に素数が残っている分を処理する
            if (restM != 1)
            {
                ans *= calcComb(1 + N - 1, N - 1); // N-1はcntと同じ
                ans %= mod;
            }

            Console.WriteLine(ans);
        }

        static long mod = 1000000007;

        // コンビネーションを求める
        // (10*9*8) / (3*2*1)
        // 10*9*8 -> ansMul
        // 3*2*1 -> ansDiv
        public static long calcComb(int a, int b)
        {
            if (b > a - b) return calcComb(a, a - b);
            long ansMul = 1;
            long ansDiv = 1;
            for (int i = 0; i < b; i++)
            {
                ansMul *= (a - i);
                ansDiv *= (i + 1);
                ansMul %= mod;
                ansDiv %= mod;
            }
            // ansMul / ansDiv を求めたい
            // ansDivの逆元を使って求める
            long ans = ansMul * modpow(ansDiv, mod - 2) % mod;
            return ans;
        }

        // aのp乗を求めるアルゴリズム
        // p=62の時、pの変化は、62->31->30->15->14->7->6->3->2->1->0 と半分半分になっていく
        // よって計算量はO(logp)になる
        public static long modpow(long a, long p)
        {
            if (p == 0) return 1;
            if (p % 2 == 0) // pが偶数の時
            {
                long halfP = p / 2;
                long half = modpow(a, halfP);
                // a^(p/2)をhalfとして、hlf*halfを計算
                return half * half % mod;
            }
            else // pが奇数の時
            {
                // pを偶数にするために1減らす
                return a * modpow(a, p - 1) % mod;
            }
        }
    }
}