Investment(完全背包)】的更多相关文章

题目链接:http://poj.org/problem?id=2063 今天果然是卡题的一天.白天被hdu那道01背包的变形卡到现在还没想通就不说了,然后晚上又被这道有个不大也不小的坑的完全背包卡了好久.这题主要是说让你选择不同的债券(每种债券的费用和年利率的属性),然后n年后使得本金最大,如果仅仅是问一年的话就是个裸完全背包的题了,不过它是n年,每年得到的总利息都会加入到本金中变为下一年的本金,知道了这个后就很好处理了,在这道题里每年变化的本金就是背包容量,然后债券那两个属性就是物品的费用(o…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1963 //多重背包 #include <cstdio> #include <cstring> #include <iostream> using namespace std; + ; #define N 15 long long dp[maxn], ans; int c[N], w[N], V; void Pack(int C, int W) { for(int i = C…
Problem Description John never knew he had a grand-uncle, until he received the notary’s letter. He learned that his late grand-uncle had gathered a lot of money, somewhere in South-America, and that John was the only inheritor. John did not need tha…
传送门: POJ:http://poj.org/problem?id=2063 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2224 大意:给你一堆本金,还有投资方案获得的利润.让你进行合理投资,要求若干年后获利最大. 完全背包问题.背包容量就是money,要尽量装满(不是风险投资哇,投资出去必获利) 开始天真的开了400多w(100万*1.1^40)的数组,直接TLE掉. 看了discuss里,因为给的利润为…
图论 图论解题报告索引 DFS poj1321 - 棋盘问题 poj1416 - Shredding Company poj2676 - Sudoku poj2488 - A Knight's Journey poj1724 - ROADS(邻接表+DFS) BFS poj3278 - Catch That Cow(空间BFS) poj2251 - Dungeon Master(空间BFS) poj3414 - Pots poj1915 - Knight Moves poj3126 - Prim…
Investment Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8019   Accepted: 2747 Description John never knew he had a grand-uncle, until he received the notary's letter. He learned that his late grand-uncle had gathered a lot of money, s…
http://poj.org/problem?id=2063 多次完全背包~ #include <stdio.h> #include <string.h> #define MAXN 50000 #define max(a,b) ((a)>(b)?(a):(b)) int dp[MAXN]; int v[11], c[11]; int main() { int t, m, year, d, i, j, k, sum; scanf("%d", &t);…
题目链接: http://poj.org/problem?id=2063 题意: 你现在有现金m元,你要做n年的存款投资,给你k种投资方式,每种需要现金vi元,能获得xi元的理论,一年到期后你要利用拿到的本息和重新投资,问这样做n年最后能拿到的最大本息和是多少. 题解: dp[i]表示你花i元去投资能获得的最大利润. 则第一年你要做的就是dp[1]->dp[m](m为初始金额) 假设获得的最大奖金为m_inte[i]: 则第二年要做的是dp[m+1]->dp[m+m_inte[i]] ...…
个人心得:炸了炸了,这背包什么的脑阔痛. 完全背包什么鬼咯,状态正向转移与01背包正好相反. 二维数组的状态转移. 一维数组的优化,注意正向覆盖. 本题中的思想 ;y<=year;y++){ ; ;i<=n;i++){ for(int j=bond[i];j<=s;j++){ dp[j]=max(dp[j],dp[j-bond[i]]+gain[i]); } } cash+=dp[s]; } John never knew he had a grand-uncle, until he r…
A - Investment Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2063 Description John never knew he had a grand-uncle, until he received the notary's letter. He learned that his late grand-uncle…