Algorithm Training k Good number time limit: 1.0s memory limit: 256.0MBProblem description
If an arbitrarily contiguous two-bit in the K-binary representation of a natural number n is not an adjacent number, then we say that this number is a K-good number. Ask for the number of K good numbers in the L-bit K-binary number. For example k = 4,l = 2, all k good numbers are 11, 13, 20, 22, 30, 31, 33 total 7. Since this is a large number, please output it to 1000000007 after the modulo value.
Input format
The input contains two positive integers, K and L.
Output format outputs an integer that represents the value after which the answer is modulo 1000000007. Sample Input 4 2 sample output 7 data size and conventions
For 30% of the data, KL <=6;
For 50% data, K <=, L <= 10;
For 100% of data, 1 <= k,l <= 100.
Exercises
Very simple DP, take the mold kneeling, absorb a lesson, I was from high to low DP, from left to right in turn is the first three-way ..., dp[i][j]
is the number I digit J possible, so dp[i][j] is equal to the previous length of all possible except its adjacent to it. This question can be added one more
ring to calculate the former and, I directly in the previous one put this and counted well, and then minus the adjacent, would like to reduce the complexity of, did not think to dig himself
A hole, because of the subtraction, so the modulus to the error plus O (╯-╰) o
Code:
Algorithm Training k good number "Blue Bridge Cup"