HDU 1059 dividing multiple backpack

Source: Internet
Author: User

/* is a multi-backpack problem, in fact, I still do not understand the backpack, but with the dynamic equation of memory can be played can be AC code, but also strange */#include <iostream>//00451533 2010-07-10 18:40:39 Accepted 1005 412 KB Visual C + + regrets Sheng #include <cstdio> #include <cstring> using namespace std; const int N = 60005; int main () {int kind[7]; int t = 1; while (1) {int sum = 0; int val = 0; for (int i = 1; I <= 6; i++) {scanf ("%d", &am P;kind[i]); Kind[i]%= 10;//This sentence did not add on the tle val + = i * kind[i]; Sum + = Kind[i]; } if (sum = = 0) break; if (VAL/2! = VAL-VAL/2) {printf ("Collection #%d:/n", t++); printf ("Can ' t be divided./n/n"); continue;} int dp[n]; memset (DP, 0, sizeof (DP)); for (int i = 1, i <= 6; i++) for (int j = 1; J <= Kind[i]; j + +) for (int k = VAL/2; k >= i; k--) dp[k] = max (dp[k) , Dp[k-i] + i); if (dp[val/2] = = VAL-VAL/2) {printf ("Collection #%d:/n", t++), printf ("Can be divided./n/n"),} else {printf ("Colle Ction #%d:/n ", t++); printf ("Can ' t be divided./n/n"); } } }

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.