poj1837 01背包类型计数
来源:互联网 发布:数控编程工资月薪过万 编辑:程序博客网 时间:2024/06/18 08:15
//有一个天平,天平左右两边各有若干个钩子,总共有C个钩子,有G个钩码,求将钩码全部挂到钩子上使天平平衡的方法的总数。//其中可以把天枰看做一个以x轴0点作为平衡点的横轴//因为强制用所有的砝码那么与用于不用对应两种状态//1424K0MS#include <iostream>#include <stdio.h>#include <string.h>using namespace std;#define MAXN 22#define MAXL 15005#define HALFL 7500static int dp[MAXN][MAXL];static int C,G;static int CS[MAXN];static int GX[MAXN];int main(){scanf("%d %d",&C,&G);for (int i=0;i<C;++i) scanf("%d",&CS[i]);for (int i=0;i<G;++i) scanf("%d",&GX[i]);memset(dp,0,sizeof(dp));for (int k=0;k<C;++k){int w = CS[k]*GX[0];dp[0][w+HALFL] = 1;}for (int i=1;i<G;++i){for (int j=0;j<MAXL;++j){if (dp[i-1][j])for (int k=0;k<C;++k){int w = GX[i]*CS[k] + j - HALFL;dp[i][w+HALFL] += dp[i-1][j];}}}printf("%d\n",dp[G-1][HALFL]);return 0;}
0 0
- poj1837 01背包类型计数
- poj1837(01背包)
- POJ1837:Balance(01背包)
- POJ1837:Balance(01背包)
- poj1837--01背包
- poj1837(01背包)
- POJ1837-Balance(01背包)
- POJ1837 动态规划 (01背包)
- Balance poj1837 (DP & 01背包)
- poj1837-Balance(01背包)
- poj1837【背包】
- 1(好好理解)poj1837(01背包)
- poj1837(分组背包)
- poj1837 balance 背包
- POJ1837--二维背包
- [背包]poj1837 Balance
- POJ1837 Balance 分组背包
- 【POJ1837】Balance,带负体积状态的01背包,水题
- C语言printf函数
- IE7中图片链接有边框问题解决方法
- java synchronized详解
- Fragment重叠问题
- 自定义TimeButton验证码倒计时
- poj1837 01背包类型计数
- You have not concluded your merge (MERGE_HEAD exists)
- Ubuntu下mysql安装,登录
- VB.Net刷点击
- Householder
- 我的第一篇博客
- mysql事件调度器
- 第一篇博客:关于学堂在线的操作系统实验准备工作
- Hibernate.util