翻译信息学竞赛题目

来源:百度知道 编辑:UC知道 时间:2024/05/21 06:19:23
When Issac Bernand Miller takes a trip to another country, say to France, he exchanges his US dollars for French francs. The exchange rate is a real number such that when multiplied by the number of dollars gives the number of francs. For example, if the exchange rate for US dollars to French francs is 4.81724, then 10 dollars is exchanged for 48.1724 francs. Of course, you can only get hundredth of a franc, so the actual amount you get is rounded to the nearest hundredth. (We'll round .005 up to .01.) All exchanges of money between any two countries are rounded to the nearest hundredth.
Sometimes Issac's trips take him to many countries and he exchanges money from one foreign country for that of another. When he finally arrives back home, he exchanges his money back for US dollars. This has got Issac thinking about how much if his unspent US dollars is lost (or gained!) to these exchange rartes. You'll compute how much money Issac ends up with if he exchanges it many

题目大意:输入前五行是五个国家的汇率,从1-5编号,第i行的五个汇率,是第i个国家依次与五个国家之间的汇率,这样第i行第j个数据就是第i个国家到第j个国家的货币汇率,第i个国家到它自身的汇率总是1,第一个国家是美国,其后,每一行表示一次旅行,输入国家的旅行顺序,然后再输入初始钱数,输入0时,表示结束,输出,每个旅行产生一个输出,给出他旅途返回时所拥有的美元数,若数量小于1美元,在美元的位置应输出0。每组数据之间有一个空行。
算法分析:可以用一个2为数组来存放五个国家之间的汇率,用一个一维数组来存放旅程当中的国家的序号,然后就是做连乘就可以了,最后输出乘积即为剩余的钱数。