[By-bit DP]

Source: Internet
Author: User

In my understanding, the bitwise DP is used to find the number or the most value that satisfies a certain nature in the range [a, B. For example, a positive integer in the statistical interval [a, B] that does not contain leading zero and the difference between two adjacent numbers is at least 2 can be solved by using a one-bit DP.

In general, one-dimensional DP State indicates the first I bit of the number currently planned, so there are two situations when processing all the states of the I + 1 bit: 1. the first I bit is not the upper and lower bounds, so that I + 1 can take any number. 2. The first I bit is the upper and lower bounds. If it is the upper bound, the I + 1 bit can only take the number smaller than or equal to the upper bound B I + 1 bit. In this way, the bitwise DP can add a one-dimensional state to express whether the boundary is reached to deal with these two situations. Then, based on the problem, add several dimensions to deal with different properties to implement bitwise DP.

HDU 3555

Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 3555

Assume that the number does not contain 49. For the first I-bit end, there are three conditions: 4 and 49. In other cases, the three States can construct an automatic machine, when the status is transferred, make sure that the status at the end of 4 is not converted to the end of 49, which is similar to the status of the automatic DP.

HDU 3709

Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 3709

Two more dimensions indicate the difference between the position of the axis and the weight of the first I bit. Pay attention to the details of repeated counting because of the different positions of the axis.

HDU 3565

Http://acm.hdu.edu.cn/viewcode.php? Rid = 3354696

There are many details. I use seven States to describe which parts of Bi-peak have been formed by the first I-bit (0 ,_,_/,_/\,_/\_, _/\ _/, _/\) to establish a Conversion Relationship between the seven States. Because it is the best value, we cannot use the range subtraction method. We need to directly use the upper and lower bounds to DP and use two binary bits to indicate whether the upper and lower bounds are reached.

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.