寒假学习第九天

今天没什么想说的  emmmmm

直接上题吧

                                      Exchange Rates

      Now that the Loonie is hovering about par with the Greenback, you have decided to use your $1000 entrance scholarship to engage in currency speculation. So you gaze into a crystal ball which predicts the closing exchange rate between Canadian and U.S. dollars for each of the next several days. On any given day, you can switch all of your money from Canadian to U.S. dollars, or vice versa, at the prevailing exchange rate, less a 3% commission, less any fraction of a cent.
Assuming your crystal ball is correct, what's the maximum amount of money you can have, in Canadian dollars, when you're done?

输入:

The input contains a number of test cases, followed by a line containing 0. Each test case begins with 0 <d ≤ 365, the number of days that your crystal ball can predict. d lines follow, giving the price of a U.S. dollar in Canadian dollars, as a real number.

输出:

For each test case, output a line giving the maximum amount of money, in Canadian dollars and cents, that it is possible to have at the end of the last prediction, assuming you may exchange money on any subset of the predicted days, in order.

翻译:

                                                                    汇率
现在,洛尼与Greenback持平,你决定用1000美元的入学奖学金从事货币投机。因此,你凝视着一个水晶球,它预测未来几天加拿大和美元之间的收盘汇率。在任何一天,你都可以按照现行汇率,减去3%的佣金,再减去0.5美分,将你所有的钱从加拿大换成美元,反之亦然。
假设你的水晶球是正确的,当你完成后,你能拥有的最高金额是多少(以加元计)?


输入:
输入包含多个测试用例,后跟一行0。每个测试用例从0<d开始≤ 365,你的水晶球可以预测的天数。随后是d行,给出了以加元表示的美元价格,作为实数。


输出:
对于每个测试用例,输出一行,给出在上一次预测结束时可能拥有的最大金额,以加元和美分为单位,假设您可以按顺序在预测日期的任何子集上兑换货币。

动态规划的题有点多   害
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值