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 max = 510000;

    let mut com = COM::new(max, p);
    com.init();

    let v = prime_factorize(m);

    let mut ans = 1;
    for &nv in &v {
        let tmp = com.com(n - 1 + nv.1, nv.1);
        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
}

struct COM {
    fac: Vec<isize>,
    finv: Vec<isize>,
    inv: Vec<isize>,
    max: usize,
    m: isize,
}

impl COM {
    fn new(max: usize, m: isize) -> Self {
        COM {
            fac: vec![0; max],
            finv: vec![0; max],
            inv: vec![0; max],
            max: max,
            m: m
        }
    }

    fn init(&mut self) {
        self.fac[0] = 1;
        self.fac[1] = 1;
        self.finv[0] = 1;
        self.finv[1] = 1;
        self.inv[0] = 0;
        self.inv[1] = 1;

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

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