Algorithm Training k good number "Blue Bridge Cup"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.