Problem:
Score : 300 points

Problem Statement

You are given an integer N.
Find the number of the positive divisors of N!, modulo 10^9+7.

Constraints

1≤N≤10^3

Input

The input is given from Standard Input in the following format:

N

Output

Print the number of the positive divisors of N!, modulo 10^9+7.

Sample Input 1

3

Sample Output 1

4

There are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.

Sample Input 2

6

Sample Output 2

30

Sample Input 3

1000

Sample Output 3

972926972

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::vec::Vec;
use std::collections::HashMap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

const MOD: usize = 1_000_000_000 + 7;

fn main() {
  let n: usize = read();
  let mut map = HashMap::new();
  let mut ans = 1;

  for i in 1..n+1 {
    let hash = trial_division(i);
    //println!("i = {} hash = {:?}",i,  hash);
    for (key, count) in hash.into_iter() {
      match map.get(&key) {
          Some(&val) => {
            map.insert(key, val + count);
          },
          _  => { map.insert(key, count); },
      }
    }
  }
  map.remove(&1);
  //println!("{:?}", map);
  for (key, count) in map.into_iter() {
    ans *= (count + 1);
    ans %= MOD;
  }
  println!("{}", ans);
}





// 試し割り
// O(√N)
fn trial_division(n :usize) -> HashMap<usize, usize>{
    let mut primes = HashMap::new();
    let mut i = 2;
    let mut n = n;

    //  n を root n 以下の整数で割り切れるまで割っていく
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            // match primes.get_mut(&i) {
            //   None => { primes.insert(i, 1); },
            //   Some(x) => {
            //       *x += 1;
            //   },
            // }

            match primes.get(&i) {
              Some(&val) => {
                primes.insert(i, val + 1);
              },
              _  => { primes.insert(i, 1); },
            }
        }
        i+=1;
    }

    // 最後にnが素数になっている場合はそれ自身も素因数に含めて終了
    // match primes.get_mut(&n) {
    //   None => { primes.insert(n, 1); },
    //   Some(x) => {
    //     *x += 1;
    //   },
    // }

     match primes.get(&n) {
          Some(&val) => {
            primes.insert(n, val + 1);
          },
          _  => { primes.insert(n, 1); },
      }

    primes
}