20ZR popularized five consecutive test Day1

arrangement

How many length is nnPermutation of n PPP satisfies∣ i − P i ∣ ≤ 1 |i-P_i|\leq1iPi1 , 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-1i1 , 让i − 1 i-1i1 position filliii , so transfer tofi = fi − 1 + fi − 2 f_i = f_{i-1}+f_{i-2}fi=fi1+fi2. 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


Did the original question

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.

Guess you like

Origin blog.csdn.net/qq_39984146/article/details/108566791