Cyclic
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 193 Accepted Submission(s): 125
Problem Description
Count the number of cyclic permutations of length n with no continuous subsequence [i, i + 1 mod n].
Output the answer modulo 998244353.
Input
The first line of the input contains an integer T , denoting the number of test cases.
In each test case, there is a single integer n in one line, denoting the length of cyclic permutations.
1 ≤ T ≤ 20, 1 ≤ n ≤ 100000
Output
For each test case, output one line contains a single integer, denoting the answer modulo 998244353.
Sample Input
Sample Output
题意:求满足一个方向的(a[i]+1)%n!=a[i+1]循环数列的n个数字组成的数列的可能性
分析:首先按照题目的意思做一个全排列列出前面几项的可能数
#include
接着找规律
AC代码:
#include