andre_joy

导航

2012年9月26日

poj 1837

摘要: 地址:http://poj.org/problem?id=1837题意:一个天枰,左边右边总共有n个钩子,总共有m个砝码,要求钩子可以不全用,砝码必须全用的所有方案数。mark:这题可以这样想,每一个砝码挂在每一个位置有一个权值,那么就组成了一个m*n的矩阵,然后需要在每一行里面选出一个使得最后权值和为0,则转移方程为dp[i][pos[j]*w[i]+k] = dp[i-1][k]。因为这里面权值可能有负数,而最大可能是-15*25*20 = -7500,所以数组可以把7500当0用。代码:#include <stdio.h>#include <string.h>#i 阅读全文

posted @ 2012-09-26 19:36 andre_joy 阅读(137) 评论(0) 推荐(0) 编辑

hdu 1712

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1712题意:复习课程,n们课,有m天复习,a[i][j]代表用j天来复习第i门课的收获。。(这里居然可能用的天数多而收获更少……囧)mark:第一个分组背包。对于每个i最多只能选一个j,或者不选。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>const int N = 110;int w[N],dp[N];int max(int a, int b) {return a > b ? a : b 阅读全文

posted @ 2012-09-26 13:51 andre_joy 阅读(138) 评论(0) 推荐(0) 编辑