6848.Christmas Party

Time Limit: 1s Memory Limit: 512MB

There are $n$ children at a Christmas party, and each of them has brought a gift. The idea is that everybody will get a gift brought by someone else.

In how many ways can the gifts be distributed?

Input Format(From the terminal/stdin)

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

  • $1 \le n \le 10^6$

Output Format(To the terminal/stdout)

Print the number of ways modulo $10^9+7$ .

Sample Input

Copy
4
 \n

Sample Output

Copy
9
 \n
Source: CSES, Mathematics, 1717

Submit

请先 登录

© 2025 FAQs