daily pastebin goal
41%
SHARE
TWEET

Newspaper

a guest Jun 13th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main(){
  7.     int tc, i, j, cnt = 0, t, k;
  8.  
  9.     scanf("%d ", &tc);
  10.  
  11.     while(tc--){
  12.         scanf("%d", &t);
  13.         char ch[t];
  14.         int val[t], tStr, len;
  15.         double total = 0;
  16.         char str[15000];
  17.  
  18.         for(i = 0; i < t; i++){
  19.             scanf(" %c %d", &ch[i], &val[i]);
  20.         }
  21.         scanf(" %d ", &tStr);
  22.  
  23.         for(i = 0; i < tStr; i++){
  24.             scanf(" %[^\n]", str);
  25.  
  26.             len = strlen(str);
  27.  
  28.             for(j = 0; j < len; j++){
  29.                 for(k = 0; k < t; k++){
  30.                     if(str[j] == ch[k]){
  31.                         total += val[k];
  32.                         break;
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.         int dollar = total / 100.0;
  38.         int cents = total - (dollar * 100.0);
  39.         if(cents < 10){
  40.             printf("%d.0%d$\n", dollar, cents);
  41.         } else {
  42.             printf("%d.%d$\n", dollar, cents);
  43.         }
  44.         memset(val, 0, t);
  45.         memset(ch, 0, t);
  46.         memset(str, 0, len);
  47.     }
  48.  
  49.     return 0;
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top