ACM: dp题 --> 背包问题 poj 1837
来源:互联网 发布:深圳阿里云大厦 编辑:程序博客网 时间:2024/05/27 09:45
Description
Gigel has a strange "balance" and he wants to poise it.Actually, the device is different from any other ordinarybalance.
It orders two arms of negligible weight and each arm's length is15. Some hooks are attached to these arms and Gigel wants to hangup some weights from his collection of G weights (1<= G <= 20) knowing that theseweights have distinct values in the range 1..25. Gigel may droopany weight of any hook but he is forced to use all theweights.
Finally, Gigel managed to balance the device using the experiencehe gained at the National Olympiad in Informatics. Now he wouldlike to know in how many ways the device can be balanced.
Knowing the repartition of the hooks and the set of the weightswrite a program that calculates the number of possibilities tobalance the device.
It is guaranteed that will exist at least one solution for eachtest case at the evaluation.
Input
The input has the following structure:
• the first line contains the number C (2 <= C<= 20) and the number G (2 <= G<= 20);
• the next line contains C integer numbers (these numbers are alsodistinct and sorted in ascending order) in the range -15..15representing the repartition of the hooks; each number representsthe position relative to the center of the balance on the X axis(when no weights are attached the device is balanced and lined upto the X axis; the absolute value of the distances represents thedistance between the hook and the balance center and the sign ofthe numbers determines the arm of the balance to which the hook isattached: '-' for the left arm and '+' for the right arm);
• on the next line there are G natural, distinct and sorted inascending order numbers in the range 1..25 representing theweights' values.
Output
The output contains the number M representing the number ofpossibilities to poise the balance.
Sample Input
2 4
-2 3
3 4 5 8
Sample Output
2
题意: 现在给你力距值C个, 砝码的g个的重量. 现在要你求是杠杆平衡的次数.
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 7505
int c, g;
int cc[25], gg[25];
int dp[22][MAX*2];
int main()
{
//
}
- ACM: dp题 --> 背包问题 poj 1837
- ACM: 回文串 dp题 poj 1159 (滚动…
- 总结: 数塔问题 --> dp 问题 (终…
- 1837 Balance dp 背包
- ACM: dp题 poj 1276 go on 动态规…
- ACM: 最长子序 dp题 poj 2533
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: 树状DP 动态规划题 poj 1463 …
- ACM: 动态规划题 poj 2057 树状DP
- ACM: 动态规划题 poj 3211 背包变…
- ACM: 动态规划题 poj 3093 0-1背包
- POj 2379 ACM Rank Table
- ACM: DP训练好题 动态规划题 poj 1…
- ACM: 简单数塔题 dp题 poj 3176
- ACM: 最优解 dp题 poj 1260
- ACM: DP+floyd 动态规划题 poj 117…
- ACM: 概率DP 动态规划题 poj 1322
- ACM: 简单数塔题 dp题 poj 3176
- ACM: 最优解 dp题 poj 1260
- ACM: 最长升序和最长降序 dp题 poj…
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题 poj 1276 go on 动态规…
- ACM: dp题 --> 背包问题 poj 1837
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: hash题 poj 3274 (题目看了好…
- ACM: 模拟题 poj 2993
- ACM: 有难度的深搜题 poj 3373
- ACM: 条件最短路 poj 1724 (没剪枝…
- ACM: 深搜题 poj 3411
- ACM: polya模拟 数论题 poj 1026
- ACM: 高精度运算 poj 1001 首次jav…