Poj-1837 balance ***

Source: Internet
Author: User
/* [Transfer]
*
* D [I] [J] indicates that when the first I object is attached, the equilibrium degree is J.
* (J> 0 indicates the weight on the left, j = 0 indicates the balance of the balance, and j <0 indicates the weight on the right) indicates the number of failures,
* Based on the question, the value range of J can be [-,]. Therefore, the state transition equation is as follows:
* D [I] [J] + = (d [I-1] [J-weigh [k] * POS [I]),
* Weigh [k] indicates the position of the K hook. Pos [I] indicates the weight of the I weight.
* Because j-weigh [k] * POS [I] may be negative, 7500 is added,
* The initial state d [0] [7500] = 1 (the balance at this time) indicates that there is no need for an object and there is only one method for balancing the balance.
*
*
*/

# Include <cstdio>
# Include <cstring>
Using namespace STD;

Const int max1 = 7500, max2 = 50;
Int C, G, weigh [max2], POS [max2], d [max2] [max1 * 2];


Int main (){
Scanf ("% d", & C, & G );
For (INT I = 1; I <= C; I ++)
Scanf ("% d", & Pos [I]);
For (INT I = 1; I <= g; I ++)
Scanf ("% d", & welap [I]);

Memset (D, 0, sizeof (d ));
D [0] [max1] = 1;
For (INT I = 1; I <= g; I ++ ){
For (Int J = 0; j <= max1 * 2; j ++)
For (int K = 1; k <= C; k ++)
D [I] [J] + = d [I-1] [J-weigh [I] * POS [k];

}

Printf ("% d \ n", d [g] [max1]);

Return 0;
}

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.