2019.10.6 Oi game simulation summary T3: linear DP

Count
subject description
given positive integer n-; m . Will the present number of length n of the array ( A . 1 ; A 2 :::;; A n ) satisfies the following properties.
for each . 1 I n- , there . 1 A I m .
For all true . 1 j m is an odd number j , are met: the array ( A . 1 ;:::; A n- ) in j number of occurrences is an even number .
Since the answer can be large, please answer mode output 10 9 + 7 results.
Enter
the first line an integer t , expressed t group query.
Next t rows, each row having two spaces separated by a positive integer n-; m .
Output
Output t lines answer.
Sample input
2
. 3 1
. 3 2
Sample output
04
Sample explain
the second sample may be all (1 ; 1 ; 2) ; (1 ; 2 ; 1) ; (2 ; 1 ; 1) ; ( 2 ; 2 ; 2) .
Data size and agreed
a total of 10 data.
For the first . 1 data, n- . 7 ; m . 7 .
For the first 3 data, n- 1000 ; m 10 .
For the first 4, data, n- 300 ; m 300 .
For the first . 6 data, n- 2000 ; m 2000 .
For the first . 7 data, n- 100000 ; m 100000.
For all data, . 1 T . 5 , . 1 n- 10 . 9 ; . 1 m 100000. .

analysis:

1. The set F [i] [j] denotes the number i before, to fill the i-th, j-th odd number is filled with a total number of odd number of times the program

2. Calculate the number of the total number of surprising A = ceil (M / 2), the total number is an even number B = M / 2

3. Consider the state transition equation

Divided into several categories: (1) before being filled i odd number even number, (2) to be filled before i odd number odd number, (3) an even number

v = 1E9 + 7;

Consider + 1 is placed in these three numbers i:

(1), is filled will increase the number of odd-numbered i.e. a f [i + 1] [k + 1] + = f [i] [k] * (Ak)% mod;

(2) that is filled will increase even number of times a number, odd number is reduced i.e. a f [i + 1] [k-1] + = f [i] [k] * k% mod

(3), i.e. no effect on the odd-f [i + 1] [k] + = f [i] [k] * B% mod;

(Positive solutions magical?)

Each even (without limitation) the exponential generating function is [Sigma I 0 X I / I ! = E X . Each odd (limit number of times i is an even
number) is the exponential function generation [Sigma i 0 X 2 i / 2 i =! ( E X + E - X ) / 2 .
A total m / 2 odd and m / 2 even number, then all together is by
(( E X + E - X ) / 2) m/ 2 E X m / 2
. The answer is that it's the first n times coefficient multiplied by n ! .
The left side of the brackets with the binomial theorem to expand, and then each individual count plus up on it

Guess you like

Origin www.cnblogs.com/little-cute-hjr/p/11628426.html