Self-Describing Sequences
Time limit1sMemory limit256 MB
Count length-N sequences where each entry A[i] equals the number of times i appears in the sequence.
- Level
Hard8 of 10
- Topics
- Math, Combinatorics, Backtracking
- Solved
- No attempts yet
Problem
You are given a natural number . A sequence of length is self-describing when the following holds for every with .
equals the number of times the value occurs in .
Count the self-describing sequences of length .
Input
The first line contains a natural number , the number of test cases. Each of the next lines contains one sequence length .
Output
For each test case, print on one line the number of self-describing sequences of length , taken modulo 1,000,000,007.
Hint
For the only sequence that satisfies the condition is . For there are two, and .