AtCoder Regular Contest 067
E
Grouping
AtCoder
⌀ 2190
原题
←F →
翻译中…

Problem Statement

翻译中…

There are $N$ people, conveniently numbered $1$ through $N$. We want to divide them into some number of groups, under the following two conditions:

翻译中…
  • Every group contains between $A$ and $B$ people, inclusive.
  • Let $F_i$ be the number of the groups containing exactly $i$ people. Then, for all $i$, either $F_i=0$ or $C≤F_i≤D$ holds.
翻译中…

Find the number of these ways to divide the people into groups. Here, two ways to divide them into groups is considered different if and only if there exists two people such that they belong to the same group in exactly one of the two ways. Since the number of these ways can be extremely large, print the count modulo $10^9+7$.

翻译中…

Constraints

翻译中…
  • $1≤N≤10^3$
  • $1≤A≤B≤N$
  • $1≤C≤D≤N$
翻译中…

Input

翻译中…

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

翻译中…

N A B C D

翻译中…

Output

翻译中…

Print the number of ways to divide the people into groups under the conditions, modulo $10^9+7$.

翻译中…

样例

Input #1
3 1 3 1 2
Output #1
4
There are four ways to divide the people: - $(1,2),(3)$ - $(1,3),(2)$ - $(2,3),(1)$ - $(1,2,3)$ The following way to divide the people does not count: $(1),(2),(3)$. This is because it only satisfies the first condition and not the second.
Input #2
7 2 3 1 3
Output #2
105
The only ways to divide the people under the conditions are the ones where there are two groups of two people, and one group of three people. There are $105$ such ways.
Input #3
1000 1 1000 1 1000
Output #3
465231251
Input #4
10 3 4 2 5
Output #4
0
The answer can be $0$.
题目信息
题号
arc067_c
时间限制
2 s
内存限制
256 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。