-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11340 - Newspaper.cpp
47 lines (42 loc) · 1007 Bytes
/
11340 - Newspaper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "bits/stdc++.h"
using namespace std;
int main()
{
int T; cin >> T;
while(T--)
{
int N; cin >> N;
map <char, int> Map;
for(int i = 0; i < N; i++)
{
char Ch;
int temp;
cin >> Ch >> temp;
Map[Ch] = temp;
}
int K; cin >> K;
map <char,int> Map2;
cin.ignore();
for(int i = 0; i < K; i++)
{
string str;
getline(cin,str);
for(int j = 0; j < str.length(); j++)
{
Map2[str[j]]++;
}
}
map <char,int> :: iterator it1, it2;
double Sum = 0;
for(it1 = Map.begin(); it1 != Map.end(); ++it1)
{
for( it2 = Map2.begin(); it2 != Map2.end(); ++it2)
{
if(it1->first == it2->first)
Sum += it1->second * it2->second;
}
}
printf("%0.2lf$\n", Sum/100);
}
return 0;
}