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)