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 C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;
#define int long long

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define ll long long
const int mod=1e9+7;
const ll MX=1<<30;

ll powmod(ll n,ll k){
    if (k==0) return 1;
    else if (k%2==0){
        ll tmp=powmod(n,k/2);
        return tmp*tmp%mod;
    }
    else return powmod(n,k-1)*n%mod;
}

int n,a,b,c,d;
ll dp[1005][1005];
ll fact[1005];
ll comb[1005][1005];

signed main()
{
    scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
    rep(i,n+1){
        dp[i][0]=1;
    }
    fact[0]=1;
    rep2(i,1,n+1){
        fact[i]=fact[i-1]*i%mod;
    }
    comb[0][0]=1;
    rep2(i,1,n+1){
        comb[i][0]=1;
        rep2(j,1,n+1){
            comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%mod;
        }
    }
    rep2(i,1,n+1){
        if(i<a || b<i) continue;
        rep2(j,1,n+1){
            rep(k,j/i+1){
                if(d<k) break;
                if((c<=k&k<=d)&(a<=i&i<=b)){
                    ll tmp=powmod(fact[i],(mod-2)*k)*powmod(fact[k],mod-2)%mod;
                    dp[i][j]+=comb[n-j+i*k][i*k]*fact[i*k]%mod*tmp%mod*dp[i-1][j-i*k]%mod;
                    dp[i][j]%=mod;
                }
                else if(k==0){
                    dp[i][j]+=dp[i-1][j];
                    dp[i][j]%=mod;
                }
            }
        }
    }
    printf("%lld\n", dp[n][n]);;

}