Language: C++


#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

ll mo = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x(x%mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
};
mint dp[1010][1010];
ll fac[1010];
ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mo;
		a = a * a % mo;
		n >>= 1;
	}
	return res;
}

int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	fac[0] = 1;
	rep(i, 1, 1010) {
		fac[i] = i * fac[i - 1];
		fac[i] %= mo;
	}

	dp[a - 1][n] = 1;
	for (int i = a; i <= b; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] += dp[i - 1][j];
			for (int k = c; k <= d; k++) {
				if (j + k * i > n)break;
				mint tmp = 0;
				mint st = fac[j + k * i];
				tmp += st * dp[i - 1][j + k * i];
				tmp *= modpow(fac[k], mo - 2);
				tmp *= modpow(fac[j], mo - 2);
				tmp *= modpow(modpow(fac[i], mo - 2), k);
				dp[i][j] += tmp;
			}
		}
	}
	puts(dp[b][0].x)

	return 0;
}


Compiler output:
a.cc: In constructor 'mint::mint(ll)':
a.cc:39:29: error: 'mod' was not declared in this scope; did you mean 'modf'?
   39 |         mint(ll x = 0) :x(x%mod) {}
      |                             ^~~
      |                             modf
a.cc: In member function 'mint& mint::operator+=(mint)':
a.cc:41:35: error: 'mod' was not declared in this scope; did you mean 'modf'?
   41 |                 if ((x += a.x) >= mod) x -= mod;
      |                                   ^~~
      |                                   modf
a.cc: In member function 'mint& mint::operator-=(mint)':
a.cc:45:27: error: 'mod' was not declared in this scope; did you mean 'modf'?
   45 |                 if ((x += mod - a.x) >= mod) x -= mod;
      |                           ^~~
      |                           modf
a.cc: In member function 'mint& mint::operator*=(mint)':
a.cc:49:31: error: 'mod' was not declared in this scope; did you mean 'modf'?
   49 |                 (x *= a.x) %= mod;
      |                               ^~~
      |                               modf