题目描述:
解题思路:
额,水题。
代码:
1 #include2 #include 3 #include 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 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 }