/***
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
int main()
{
//Try to avoid using two nested for loop by two array
//it increase program complexity
int test,k,i,item;
long int v,N ;
char ch, str[10001];
map<char,long int>datamap;
double price;
while(sc("%d",&test)==1){
while(test--){
price =0 ;
sc("%d",&k);
i=0;
while(k--){
getchar();
sc("%c %ld",&ch,&v);
datamap[ch] = v;
}
item = i ;
sc("%ld",&N);
getchar();
while(N--){
gets(str);
for(int j=0 ; j<strlen(str);j++){
if(datamap[str[j]]){
price = price+ datamap[str[j]];
}
}
}
pf("%.2lf$\n",price/100);
datamap.clear();
}
}
return 0;
}
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
int main()
{
//Try to avoid using two nested for loop by two array
//it increase program complexity
int test,k,i,item;
long int v,N ;
char ch, str[10001];
map<char,long int>datamap;
double price;
while(sc("%d",&test)==1){
while(test--){
price =0 ;
sc("%d",&k);
i=0;
while(k--){
getchar();
sc("%c %ld",&ch,&v);
datamap[ch] = v;
}
item = i ;
sc("%ld",&N);
getchar();
while(N--){
gets(str);
for(int j=0 ; j<strlen(str);j++){
if(datamap[str[j]]){
price = price+ datamap[str[j]];
}
}
}
pf("%.2lf$\n",price/100);
datamap.clear();
}
}
return 0;
}
No comments:
Post a Comment