问题 3130 --2421:Exchange Rates (汇率)

3130: 2421: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?
起始有1000元美元,给出N天美元与加拿大元的汇率。问N天内可以不停的兑换,每次兑换需要收取3%的手续费,问可以得到的最大的美元数。

输入

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.
包含多组测试数据,每组数据给定天数d ( 0<d365),以下 d 行为以后每天的汇率。

输出

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.
每组数据一个数,即最大的美元数(保留2位小数)。

样例输入输出

输入#1 复制
3
1.0500
0.9300
0.9900
2
1.0500
1.1000
0
输出#1 复制
1001.60
1000.00

提示

序号 标题 作者 发表时间 费用 订购数 操作