immuntasir

Untitled

Nov 13th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <cstdio>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5. int main() {
  6. std::ios_base::sync_with_stdio(false);
  7. freopen("in.txt", "r", stdin);
  8. freopen("out.txt", "w", stdout);
  9. int t;
  10. cin >> t;
  11. while (t--) {
  12. int ara[300] = {0};
  13. int n, in2, i, ans =0;
  14. char in1;
  15. cin >> n;
  16. while (n--) {
  17. cin >> in1 >> in2;
  18. ara[in1] = in2;
  19. }
  20. cin >> n;
  21.  
  22. string str;
  23. cin>>str;
  24. while (n--) {
  25. i=0;
  26.  
  27. getline(cin, str);
  28. while (str[i]!='\0') {
  29. ans += ara[str[i]];
  30. i++;
  31. }
  32. }
  33. cout << ans/100 << ".";
  34. ans = ans%100;
  35. if (ans/10==0) cout << "0" << ans << "$\n";
  36. else cout << ans << "$\n";
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment