题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1963

题目意思:有 本金 money,还有一些股票的种类,第 i 种股票买入需要 value[i] 这么多钱,相应会有一定的利息interest[i],问经过若干年 year 后,每年都以最优的方案投资,总的资金有多少?

完全背包题,不过要看清楚 这句话:The value of a bond is always a multiple of $1 000,否则TLE了

 #include <iostream>
#include <cstring>
#include <cstdio>
using namespace std; const int maxn = 1e6 + ; typedef long long ll;
int value[maxn], interest[maxn];
ll dp[maxn], ans, money, tolmoney; int main()
{
int kind, tcase, year;
while (scanf("%d", &tcase) != EOF)
{
while (tcase--)
{
scanf("%lld%d", &money, &year);
scanf("%d", &kind);
for (int i = ; i < kind; i++)
{
scanf("%d%d", &value[i], &interest[i]);
value[i] /= ;
}
memset(dp, , sizeof(dp));
ans = , tolmoney = money;
for (int j = ; j < year; j++)
{
if (j != )
money = tolmoney;
money /= ;
for (int i = ; i < kind; i++)
{
for (int k = value[i]; k <= money; k++)
{
dp[k] = max(dp[k], dp[k-value[i]] + interest[i]);
ans = max(dp[k], ans);
}
}
tolmoney += ans;
}
printf("%lld\n", tolmoney);
}
}
return ;
}

hdu 1963 Investment 解题报告的更多相关文章

  1. hdu 1963 Investment 多重背包

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1963 //多重背包 #include <cstdio> #include <cstr ...

  2. [HDU 1963] Investment

    Investment Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu   Descrip ...

  3. Bestcoder13 1003.Find Sequence(hdu 5064) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5064 题目意思:给出n个数:a1, a2, ..., an,然后需要从中找出一个最长的序列 b1, b ...

  4. hdu 1896.Stones 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1896 题目意思:给出 n 块石头的初始位置和能到达的距离.对于第奇数次遇到的石头才抛掷,偶数次的就忽略 ...

  5. Valentine's Day Round 1001.Ferries Wheel(hdu 5174)解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5174 题目意思:给出 n 个人坐的缆车值,假设有 k 个缆车,缆车值 A[i] 需要满足:A[i−1] ...

  6. BestCoder27 1001.Jump and Jump... (hdu 5162) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5162 题目意思:有 n 个 kid,每个 kid 有三个成绩 a, b, c.选最大的一个成绩作为这个 ...

  7. BestCoder27 1002.Taking Bus(hdu 5163) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5163 题目意思:有 n 个车站,给出相邻两个车站的距离,即车站 i 和车站 i+1 的距离为 di ( ...

  8. BestCoder25 1001.Harry and Magical Computer(hdu 5154) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5154 题目意思:有 n 门 processes(编号依次为1,2,...,n),然后给出 m 种关系: ...

  9. BestCoder14 1002.Harry And Dig Machine(hdu 5067) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5067 题目意思:给出一个 n * m 的方格,每一个小方格(大小为1*1)的值要么为 0 要么为一个正 ...

随机推荐

  1. asp.net在IE10下事件丢失排错经过

    下午看一篇文章,感觉对以后自己开发有点用途,摘抄下来. 原文出处:http://www.cnblogs.com/weapon/archive/2013/06/23/3150584.html 最近项目中 ...

  2. msp430项目编程52

    msp430综合项目---扩展项目二52 1.电路工作原理 2.代码(显示部分) 3.代码(功能实现) 4.项目总结

  3. Python入门--11--自定义函数

    使用def定义自定义函数 举个栗子: def myfristFunction(): print "we are 伐木累!" #输入myfristFunction() 会输出:we ...

  4. iOS 取应用版本

    
// 应用网址 返回字典中有多种数据 NSString *urlString2 = [NSString stringWithFormat: @"%@", @"http: ...

  5. Codeforces 667C Reberland Linguistics【DFS】

    一道卡题意的题. 题目链接: http://codeforces.com/problemset/problem/667/C 题意: 一个串可以看成一个长度大于4的根,加上其后面的若干个相邻(in a ...

  6. java 使用POI读取excel数据

    原文:http://doc.okbase.net/0201zcr/archive/161440.html 一.定义 Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Ja ...

  7. android studio——Could not find method externalNativeBuild()

    gradle同步工程时出现错误 Error:(36, 0) Could not find method externalNativeBuild() for arguments [build_cazi7 ...

  8. BEGINNING SHAREPOINT&#174; 2013 DEVELOPMENT 第3章节--SharePoint 2013 开发者工具 使用Napa开发SharePoint应用程序

    BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第3章节--SharePoint 2013 开发者工具 使用Napa开发SharePoint应用程序         假设 ...

  9. 基于jquery 全选、反选、各行换色、单击行选中事件实现代码

    <script language="javascript"> $(document).ready(function(){ //各行换色 $('table tr:odd' ...

  10. 令人赞叹的 MySQL

    原文链接 译文链接 感谢 艾凌风 小伙伴校稿 令人赞叹的 MySQL 一个很棒的 MySQL 软件.库以及资源列表. 这个列表接受并鼓舞 pull requests,请看 CONTRIBUTING 文 ...