POJ 1837
来源:互联网 发布:统计网络直报系统 编辑:程序博客网 时间:2024/06/05 15:50
经过计算最大力距为3750,所以以3750作为力距为零的点,然后DP就可以了
#include<stdio.h>#include<string.h>int dp[30][8000];//dp[i][j]代表挂上i个砝码之后总力距为j的方案数;int w[30];int p[30];int main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF){ memset(dp,0,sizeof(dp)); for(int i=0;i<n;i++) scanf("%d",&p[i]); for(int i=0;i<m;i++) scanf("%d",&w[i]); for(int i=0;i<n;i++) dp[1][w[0]*p[i]+3750]++; for(int i=1;i<m;i++){ for(int j=0;j<n;j++){ for(int k=0;k<=7500;k++){ if(dp[i][k]!=0){ dp[i+1][k+w[i]*p[j]]+=dp[i][k];//状态转移方程; } } } } printf("%d\n",dp[m][3750]); } return 0;}
0 0
- POJ 1837
- POJ 1837
- poj 1837
- poj 1837
- POJ 1837
- poj 1837
- POJ 1837
- poj.1837
- poj 1837
- poj-1837
- poj 1837
- POJ 1837
- POJ 1837
- poj 1837
- poj 1837
- POJ 1837
- poj-1837
- POJ 1837
- ps -eo uname,comm|grep `whoami`失败 用户名长度限制
- linux suse iP config
- cocos2d-x 动画
- kettle插入更新操作
- c2java 第4篇 二叉堆和Huffman编码在视频编码中的运用
- POJ 1837
- hdu 1163 Eddy's digital Roots(九余数定理,快速幂)
- week7晚作业
- Container With Most Water
- 项目二。深复制的构造函数
- 第四周作业——图的表示
- 登陆页面Checkout as guest Bug
- week7
- 系统时钟