arrangement
How many length is nnPermutation of n PPP satisfies∣ i − P i ∣ ≤ 1 |i-P_i|\leq1∣i−Pi∣≤1 , the answer is right998244353 9982443539 9 8 2 4 4 3 5 3. Take the modulus.
Setting fi f_ifiTo determine the front iiThe number of permutations of i , then theiii position oriii , otherwise fill ini − 1 i-1i−1 , 让i − 1 i-1i−1 position filliii , so transfer tofi = fi − 1 + fi − 2 f_i = f_{i-1}+f_{i-2}fi=fi−1+fi−2. The matrix can be accelerated.
Roam
Obviously the deepest chain is left last, and if the chain can finish, it must stop at the end of the chain. And you start from the root node, go xxx points and back to the root node only need2 × x 2 \times x2×x steps, so just discuss it.
colour
Interval
Give a length of nnthe sequence of n andmmm numbered intervals, ask how many legal placement schemes there are so that the number of intervals covered on each grid does not exceedttt . Number ofplans 998244353 9982443539 9 8 2 4 4 3 5 3 prime numbers modulo.