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 Haskell (GHC 7.10.3) (judge verdict: Accepted)

import Data.List
import Data.Array.IArray
import Data.Array.IO
import Control.Applicative
import Control.Monad

ub = 1000

primes = 2 : f [3] [3,5..]
  where
    f (x:xs) ys = let (ps, qs) = span (< x^2) ys in ps ++ f (xs ++ ps) [z | z<-qs, mod z x /= 0]

primes' = takeWhile (< ub) $! primes

parray = accumArray (\x y -> y) False (1,ub) [(i, True) | i<-primes'] :: Array Int Bool


primeFactorize n = pfactorize' n primes'
  where
    pfactorize' _ [] = []
    pfactorize' 1 _ = []
    pfactorize' n pr@(p:ps) =
      if parray ! n then
        [n]
      else
        if mod n p == 0 then p : (pfactorize' (div n p) pr) else pfactorize' n ps

main = do
  n <- read <$> getLine

  let factors = foldl1 (++) $ map primeFactorize [1..n]
  
  arr <- newArray (1,n) 0 :: IO (IOArray Int Integer)

  forM_ factors $ \x -> do
    r <- readArray arr x
    writeArray arr x (r+1)


  print
    =<< return . (foldl1 (\x y -> mod (x*y) (10^9+7))) . (map (+1))
    =<< getElems arr