ZOJ 1058 Currency Exchange
来源:互联网 发布:淘宝刷单降权多久恢复 编辑:程序博客网 时间:2024/05/06 09:30
When Issac Bernand Miller takes a trip to another country, say toFrance, he exchanges his US dollars for French francs. The exchangerate is a real number such that when multiplied by the number ofdollars gives the number of francs. For example, if the exchangerate for US dollars to French francs is 4.81724, then 10 dollars isexchanged for 48.1724 francs. Of course, you can only get hundredthof a franc, so the actual amount you get is rounded to the nearesthundredth. (We'll round .005 up to .01.) All exchanges of moneybetween any two countries are rounded to the nearest hundredth.
Sometimes Issac's trips take him to many countries and heexchanges money from one foreign country for that of another. Whenhe finally arrives back home, he exchanges his money back for USdollars. This has got Issac thinking about how much if his unspentUS dollars is lost (or gained!) to these exchange rartes. You'llcompute how much money Issac ends up with if he exchanges it manytimes. You'll always start with US dollars and you'll always endwith US dollars.
Input
The first 5 lines of input will be the exchange rates between 5countries, numbered 1 through 5. Line i will five the exchange ratefrom country i to each of the 5 countries. Thus the jth entry ofline i will give the exchange rate from the currency of country ito the currency of country j. the exchange rate form country i toitself will always be 1 and country 1 will be the US. Each of thenext lines will indicate a trip and be of the form
N c1 c2 �� cn m
Where 1 <= n <= 10 and c1, ��, cn are integers from 2through 5 indicating the order in which Issac visits the countries.(A value of n = 0 indicates end of input, in which case there willbe no more numbers on the line.) So, his trip will be 1 -> c1-> c2 -> �� -> cn -> 1. the real number m will be theamount of US dollars at the start of the trip.
Output
Each trip will generate one line of output giving the amount ofUS dollars upon his return home from the trip. The amount should befiven to the nearest cent, and should be displayed in the usualform with cents given to the right of the decimal point, as shownin the sample output. If the amount is less than one dollar, theoutput should have a zero in the dollars place.
This problem contains multiple test cases!
The first line of a multiple input is an integer N, then a blankline followed by N input blocks. Each input block is in the formatindicated in the problem description. There is a blank line betweeninput blocks.
The output format consists of N output blocks. There is a blankline between output blocks.
Sample Input
1
1 1.57556 1.10521 0.691426 7.25005
0.634602 1 0.701196 0.43856 4.59847
0.904750 1.42647 1 0.625627 6.55957
1.44616 2.28059 1.59840 1 10.4843
0.137931 0.217555 0.152449 0.0953772 1
3 2 4 5 20.00
1 3 100.00
6 2 3 4 2 4 3 120.03
0
Sample Output
19.98
99.99
120.01
Source: East Central North America 2001,Practice
源码:
解题报告:
- ZOJ 1058 Currency Exchange
- POJ-1860-Currency Exchange
- poj 1860 Currency Exchange(bellm…
- poj 3903 Stock Exchange
- ZOJ-1058-Currency Exchange
- ZOJ 1058: Currency Exchange
- ZOJ 1058 Currency Exchange
- zoj 1058 Currency Exchange
- zoj 1058 Currency Exchange
- ZOJ 2536 best balance
- ZOJ 3197 Goole Book
- ZOJ 1078 Palindrom Numbers
- ZOJ 1633 big string
- ZOJ 2239 In Danger
- ZOJ 1002 Fire Net
- ZOJ 1091 Knight Moves
- ZOJ 1045 Hang Over
- ZOJ 1003 Crashing Balloon
- ZOJ 1012 Mainframe
- 就一天聚义厅江特电机的得分的反而非凡
- sqlite学习笔记4:表的创建和删除
- ZOJ 1029 Moving Tables
- ZOJ 1053 FDNY to the Rescue
- ZOJ 1058 Currency Exchange
- ZOJ 1007 Numerical&nbs…
- ZOJ 1010 Area
- zoj 1006 Do the Untwist
- zoj 1009 enigma
- C++ 多态
- zoj 1011 NTA
- zoj 1062 Trees Made to Order
- zoj 1047 Image Perimeters