Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class Main {
- public static void main(String[] args) throws IOException {
- Scanner ent=new Scanner(System.in);
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- HashMap<Character,Byte>Systema=new HashMap<>();
- byte N=Byte.parseByte(br.readLine());
- for(byte i=0;i<N;i++){
- StringTokenizer jg=new StringTokenizer(br.readLine());
- Systema.put(jg.nextToken().charAt(0),Byte.parseByte(jg.nextToken()));
- }
- short K=Short.parseShort(br.readLine());
- for(short i=0;i<K;i++){
- String word=br.readLine();
- byte exp=(byte)(word.length()-1);
- byte exp2=0;
- long num=0;
- while(exp>-1){
- num+=(Systema.get(word.charAt(exp2))*Math.pow(N,exp));
- exp--;
- exp2++;
- }
- System.out.println(num);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement