Dynamic programming for integer splitting

Source: Internet
Author: User

Given a natural number, which is divided into k parts, the sum of A1, a2..., requires A1 <= a2... how many types?

Principle: the integer n is split into the split score of the sum of the maximum number of m, and the split score of the n is equal to the split score of the maximum number of m. Based on this principle, the original problem is converted into the sum of the number of k splits and the maximum number of K-1 splits (or the original problem is converted into the number of k splits. sum with the maximum number of splits split into the K-1) f (n, k) = f (n, K-1) + f (n-k, k) can actually be seen as a complete backpack problem: items have k pieces: item, 1 item, 1, 1... item k: 1, 1 ,.., 1 (k) Why can we look at this? Because A1 <= A2 is required, although in ascending order, reverse release can also be seen as descending order, so... F [I, j] = f [i-1, j] + f [I, j-cost [I] but in fact cost [I] = I so: f [I, j] = f [i-1, j] + f [I, j-I]

Dynamic programming for integer splitting

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.