loj#P552. 「LibreOJ Round #8」MIN&MAX I
「LibreOJ Round #8」MIN&MAX I
Description
For an -order permutation , we set up an undirected simple graph with vertices numbered from to .
We create an edge between each vertice and the nearest vertices in each side which correspond a greater (or less) value than .
Formally,in this graph, , the edge exists iff at least one of the following four conditions hold:
- , and no exists such that ;
- , and no exists such that ;
- , and no exists such that ;
- , and no exists such that .
Now we randomly choose a permutation from all -order permutations. Your task is to calculate the expected number of the -cycles in . You only need to output the answer modulo .
Input Format
The only line contains a positive integer which means the order of the permutation.
Output Format
Output only one line,which contains an integer which means the expected number of the -cycles in modulo .
3
665496236
91
116578319
3
665496236
91
116578319
Constraints
For all test cases, .
Detailed constraints are as follows (blank grids denote the same constraints as mentioned above):
Subtask # | Score (percentage) | |
---|---|---|
- |