Original CSES
Submit solution
Points:
100 (partial)
Time limit:
2.0s
Memory limit:
512M
Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, Dart, Go, Java, JS, Kotlin, Lua, Pascal, Perl, Prolog, Python, Rust, Scala, Swift, VB, Zig
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
The only input line has an integer n: the number of children.
Output
Print the number of ways modulo 10^9+7.
Constraints
Example
Input:
4
Output:
9
Comments