Question: Give You a c hook and W hook codes to balance your balance.
Data explanation:
2 4-2 3 3 4 5 8
If the origin is used as the pivot point,-2 indicates that there is a hook code at the left side of the pivot point. Similarly, 3 indicates the point on the right.
So an example of case data is (3 + 5) * 3 = (4 + 8) * 2 or (3 + 4 + 5) * 2 = 8*3 (arm Balance)
In either case, Output 2;
Idea: if this is not based on the topic classification, I still cannot think of this idea. I feel that I have made great progress and can independently introduce the transfer equation.
First, let's take a look at this question. First, we need to balance the force, so a limitation is the weight. The position of the hook associated with the force. Obviously, the hook code can be placed in any position, so our current status can be the number of hooks and the current Force Arm. The maximum number of hook codes is 20, and the Force Arm is 15*25*20 = 7500, with 7500 as the fulcrum, so the maximum is 15000
So we can consider when the current put a I-1 hook code, its arm is J, put the DP [I-1] [J. So when I put the I hook code at any location there is also DP [I-1] [J] method that is DP [I] [J + W [I] * C [location]
The AC code is as follows:
# Include <stdio. h> # include <string. h> int DP [25] [1, 15000]; int C [25], W [25]; int main () {int n, m; while (scanf ("% d", & N, & M )! = EOF) {int I, j; for (I = 1; I <= N; I ++) scanf ("% d", & C [I]); for (I = 1; I <= m; I ++) scanf ("% d", & W [I]); memset (DP, 0, sizeof (DP); DP [0] [7500] = 1; for (I = 1; I <= m; I ++) for (j = 1; j <= 15000; j ++) if (DP [I-1] [J]) {for (int K = 1; k <= N; k ++) // each location needs to be enumerated DP [I] [J + C [k] * W [I] + = DP [I-1] [J];} printf ("% d \ n", DP [m] [7500]); // FULCRUM} return 0 ;}