解题报告
题意:
本金买股票,最大n年后的收益(本金加利息)
思路:
基础完全背包,单纯的写可能TLE,因为股票都是1000的倍数,所以本金用1000的整数倍来买股票。
#include
#include
#include
#define inf 99999999
using namespace std;
int w[12],c[12],dp[2001000],v;
int n,d...
分类:
其他好文 时间:
2014-08-02 10:04:03
阅读次数:
275
题目:Ingenuous Cubrency
题目大意:给出一类钱,面值有1, 8, 27... (21)^3这21种,然后给出N,问N可以有多少组成方式。
解题思路:dp【i】代表面值为i的最多有多少种组合方式,状态转移方程:dp【i】 += dp【i - value【1...21]]. 如果要组成i值的话,那么它一定是由之前的状态(i - value【j】)加上现有的面值组...
分类:
其他好文 时间:
2014-08-02 10:03:13
阅读次数:
186
解题报告
题目传送门
题意:
中文不多说;
思路:
基础多重背包,每个物品有多个可以选,转换成01背包解。
#include
#include
#include
#define inf 99999999
using namespace std;
int main()
{
int t,i,j,n,m,v,p,h,cc,w[1010],c[1010],dp[1010];
...
分类:
其他好文 时间:
2014-08-02 01:52:52
阅读次数:
189
解题报告
题目传送门
题意:
给金币的面额和重量,求装满储蓄罐的最小价值。
思路:
完全背包基础,初始dp为最大,dp[0]=0表示储蓄罐为空价值为0;
状态转移方程就是dp[j]=min(dp[j],dp[j-w[i]]+c[i])
#include
#include
#include
#define inf 99999999
using namespace std;
in...
分类:
其他好文 时间:
2014-08-01 23:12:12
阅读次数:
391
题目大意是在一块M行N列的农场上种谷物,但是不希望彼此相邻(共用一条边),并且有些地方不能种植谷物,给定M,N(范围都不超过12)以及一些不能种谷物的位置,求出一共有多少种方法种谷物。
状态压缩DP,设dp(i, k) 为种到第i行时,第i行状态为k的总共方案数,可以知道dp(i, k) = ∑dp(i -1, k'),其中我们要判断彼此相邻的情况以及不能种植的情况即可。
#i...
分类:
其他好文 时间:
2014-08-01 23:08:32
阅读次数:
225
解题报告
题意:
容量为v的大小,物品数n,每个物品有价值和容量,求能装进包的最大价值。
思路:
基础01背包。
dp[j]=max(dp[j],dp[j-c[i]]+w[i])
#include
#include
#include
#define inf 99999999
using namespace std;
int main()
{
int t,i,j,n,v,...
分类:
其他好文 时间:
2014-08-01 23:07:32
阅读次数:
284
该来的总是要来的————————经典问题,石子合并。 对于 f[i][j]= min{f[i][k]+f[k+1][j]+w[i][j]}From 黑书凸四边形不等式:w[a][c]+w[b][d]#include #define N 1005int s[N][N],f[N][N],sum[N],....
分类:
其他好文 时间:
2014-08-01 22:44:12
阅读次数:
305
Robot
Problem Description
Michael has a telecontrol robot. One day he put the robot on a loop with n cells. The cells are numbered from 1 to n clockwise.
At first the robot is in ce...
分类:
其他好文 时间:
2014-08-01 19:55:22
阅读次数:
319