Poj 1837 balance (0 1 backpack)

Source: Internet
Author: User

Balance
Time limit:1000 ms   Memory limit:30000 K
Total submissions:10326   Accepted:6393
Question: give you n hook G weights and the distance between N hooks to the center of the balance (negative representing the left representing the right) the weight of G weights. Requirement output can make the balance of the method type of problem-solving ideas http://user.qzone.qq.com/289065406/blog/1299341345 is very detailed


# Include <iostream> # include <cstdio> # include <cstring> using namespace STD; int main () {int DP [25] [15005]; int N, G, c [25], W [25], I, j; while (CIN> N> G) {for (I = 1; I <= N; I ++) cin> C [I]; for (I = 1; I <= g; I ++) CIN> W [I]; memset (DP, 0, sizeof (DP); DP [0] [7500] = 1; for (I = 1; I <= g; I ++) for (j = 0; j <= 15000; j ++) if (DP [I-1] [J]) {for (int K = 1; k <= N; k ++) DP [I] [J + C [k] * W [I] + = DP [I-1] [J];} cout <DP [g] [7500] <Endl;} return 0 ;}


Poj 1837 balance (0 1 backpack)

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.