Advertisement
Nusrat_Ullah

UVa 11340

Nov 27th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int z,t,g,q;
  6.     char f;
  7.     string l;
  8.     scanf("%d",&t);
  9.     while(t--){
  10.         scanf("%d",&z);
  11.         int u[256]={0},v[256]={0};
  12.         double re=0;
  13.         while(z--){
  14.             cin>>f>>q;
  15.             u[(int)f]=q;
  16.         }
  17.         scanf("%d\n",&z);
  18.         while(z--){
  19.             getline(cin,l);
  20.             for(g=0;g<256;g++)if(u[g]){
  21.                 v[g]+=count(l.begin(),l.end(),g);
  22.             }
  23.         }
  24.         for(g=0;g<256;g++)if(u[g]){
  25.             re+=(u[g]*v[g]);
  26.         }
  27.         printf("%.2f$\n",re/100);
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement