7015.Functional Graph Distribution

Time Limit: 2s Memory Limit: 512MB

A functional graph is a directed graph where each node has outdegree $1$ . For example, here is a functional graph that has $9$ nodes and $2$ components:

2415-1.png

Given $n$ , your task is to calculate for each $k=1 \dots n$ the number of functional graphs that have $n$ nodes and $k$ components.

Input Format(From the terminal/stdin)

The only input line has an integer $n$ : the number of nodes.

  • $1 \le n \le 5000$

Output Format(To the terminal/stdout)

Print $n$ lines: for each $k=1 \dots n$ the number of graphs modulo $10^9+7$ .

Sample Input

Copy
3
 \n

Sample Output

Copy
17
9
1
  \n
 \n
 \n
Source: CSES, Counting Problems, 2415

Submit

请先 登录

© 2025 FAQs