atcoder#AGC023C. [AGC023C] Painting Machines
[AGC023C] Painting Machines
Score : points
Problem Statement
There are squares lining up in a row, numbered through from left to right. Initially, all squares are white. We also have painting machines, numbered through . When operated, Machine paints Square and black.
Snuke will operate these machines one by one. The order in which he operates them is represented by a permutation of , , which means that the -th operated machine is Machine .
Here, the score of a permutation is defined as the number of machines that are operated before all the squares are painted black for the first time, when the machines are operated in the order specified by . Snuke has not decided what permutation to use, but he is interested in the scores of possible permutations. Find the sum of the scores over all possible permutations for him. Since this can be extremely large, compute the sum modulo .
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the sum of the scores over all possible permutations, modulo .
4
16
There are six possible permutations as . Among them, and have a score of , and the others have a score of . Thus, the answer is .
2
1
There is only one possible permutation: , which has a score of .
5
84
100000
341429644