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 Rust (1.42.0) (judge verdict: Accepted)

use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let p = 1000000007;
    let v = prime_factorize(m);

    let max = 510000;

    let mut fac = vec![0; max];
    let mut finv = vec![0; max];
    let mut inv = vec![0; max];

    com_init(&mut fac, &mut finv, &mut inv, max, p);

    let mut ans = 1;
    for &nv in &v {
        let tmp = com(n - 1 + nv.1, nv.1, &fac, &finv, p);
        ans = ans * tmp % p;
    }

    println!("{}", ans);
}

fn prime_factorize(mut n: usize) -> Vec<(usize, usize)> {
    let mut res = vec![];
    let mut a = 2;
    while a * a <= n {
        if n % a != 0 {
            a += 1;
            continue;
        }
        let mut ex = 0;

        while n % a == 0 {
            ex += 1;
            n /= a;
        }

        res.push((a, ex));
        a += 1;
    }
    if n != 1 {
        res.push((n, 1));
    }

    res
}

fn com_init(
    fac: &mut Vec<isize>,
    finv: &mut Vec<isize>,
    inv: &mut Vec<isize>,
    max: usize,
    m: isize,
) {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[0] = 0;
    inv[1] = 1;

    let mut i = 2;
    while i < max {
        fac[i] = fac[i - 1] * i as isize % m;
        inv[i] = m as isize - inv[m as usize % i] * (m / i as isize) % m;
        finv[i] = finv[i - 1] * inv[i] % m;
        i += 1;
    }
}

fn com(n: usize, k: usize, fac: &Vec<isize>, finv: &Vec<isize>, m: isize) -> isize {
    if n < k {
        return 0;
    }
    fac[n] * (finv[k] * finv[n - k] % m) % m
}