immuntasir

Untitled

Nov 13th, 2015
204
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. //getchar();
  22. string str;
  23. while (n--) {
  24. i=0;
  25.  
  26. getline(cin, str);
  27. while (str[i]!='\0') {
  28. ans += ara[str[i]];
  29. i++;
  30. }
  31. }
  32. cout << ans/100 << ".";
  33. ans = ans%100;
  34. if (ans/10==0) cout << "0" << ans << "$\n";
  35. else cout << ans << "$\n";
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment