#P1968. 美元汇率
美元汇率
Description
In the coming days, David will study the exchange rate between the US dollar and the Deutsche Mark. Write a program to help David decide when he should buy or sell marks or dollars so that, starting from dollars, he can end up with the highest possible value.
Input Format
The first line of the input file contains a natural number , , which is the number of days David studies the exchange rate.
Each of the next lines contains a natural number , . The on line gives the known average exchange rate for day : on that day, David can use dollars to buy marks, and he can also use marks to buy dollars.
Output Format
Output a single line with the required amount of money (in dollars), rounded to two decimal places.
Note: Considering rounding errors in real-number arithmetic, any result within dollars of the correct answer is accepted. David must convert all his money back to dollars before the end of the last day.
5
400
300
500
300
250
266.67
Hint
Sample explanation
Day 1 ... changing 100.0000 USD= 400.0000 Mark
Day 2 ... changing 400.0000 Mark= 133.3333 USD
Day 3 ... changing 133.3333 USD= 666.6666 Mark
Day 5 ... changing 666.6666 Mark= 266.6666 USD
Updated on 2017/08/18:
- The correct answer to the sample is .
- Test point has been replaced by the sample.
- The SPJ's tolerance used to be ; according to the statement, it has been changed to .
Translated by ChatGPT 5
京公网安备 11011102002149号