ZOJ 1058 Currency Exchange

题目描述:

  http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1058

解题思路:

  额,水题。

代码:

 1 #include <iostream>
 2 #include <vector>
 3 #include <stdio.h>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     int n, i, j, k, t;
 9     double money;
10     double an[6][6];
11     vector<int> q;
12     cin >> n;
13     for(i = 0; i < n; i ++)
14     {
15         if(i != 0) printf("\n");
16         for(j = 1; j < 6; j ++)
17             for(k = 1; k < 6; k ++)
18                 cin >> an[j][k];
19         int num;
20 
21         while(cin >> num && num != 0)
22         {
23             q.clear();
24             q.push_back(1);
25             while(num --)
26             {
27                 cin >> t;
28                 q.push_back(t);
29             }
30             q.push_back(1);
31             cin >> money;
32             for(j = 0; j < q.size()-1; j++)
33             {
34                 k = q[j];
35                 t = q[j+1];
36                 money *= an[k][t];
37                 int temp = (int)((money + 0.005) * 100);
38                 money = temp / 100.00;
39             }
40             printf("%.2lf\n", money);
41         }
42     }
43 }
posted @ 2012-04-30 21:05  可乐爱上了雪碧  阅读(174)  评论(0编辑  收藏  举报