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 (Clang 3.8.0) (judge verdict: Wrong Answer)

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

long long N, M;
bool p[100000];
vector<long long> primes;
map<long long, long long> factors;
long long invm[1000];

const long long mod = 1e9 + 7;

long long fastpow(long long x, long long  n, long long m)
{
    if (n == 0)
    {
        return 1LL;
    }
    if (n % 2 == 0)
    {
        return fastpow(x * x % m, n / 2, m);
    }
    else
    {
        return x * fastpow(x, n - 1, m) % m;
    }
}

long long comb(long long a, long long b)
{
    long long ret = 1;
    for (long long i = 0; i < b;i++)
    {
        ret = (ret * (a - i)) % mod;
    }
    return (ret * invm[b]) % mod;
}

int main()
{
    cin >> N >> M;
    long long sqrtm = sqrt(M);

    for (int i = 2; i <= sqrtm; i++)
    {
        if(p[i] == false)
        {
            for (int j = 2; i * j <= sqrtm;j++)
            {
                p[i * j] = true;
            }
        }
    }

    for (int i = 2; i < 100000;i++)
    {
        if(p[i] == false)
        {
            primes.push_back(i);
        }
    }

    long long m = M;
    
    for (int i = 0; i < primes.size(); i++)
    {
        long long t = primes[i];
        while (m % t == 0)
        {
            if(factors.find(t) == factors.end())
            {
                factors.insert(make_pair(t, 1));
            }
            else
            {
                factors[t]++;
            }
            m /= t;
        }
    }

    long long ans = 1LL;

    long long a = 1;
    for (long long i = 2; i < 1000;i++)
    {
        a = (a * i) % mod;
    }

    long long ainv = fastpow(a, mod - 2, mod);
    invm[1] = 1LL;
    for (long long i = 999;i >= 2;i--)
    {
        invm[i] = ainv;
        ainv = (ainv * i) % mod;
    }

    for (auto const &f : factors)
    {
        long long b = f.second;
        ans = (ans * comb(b + N - 1, b)) % mod;
    }

    cout << ans << endl;

    return 0;
}