A Java

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Archivo: /home/misan/gcj/2009/1C/A/A.

java Página 1 de 1

import java.util.*;
import java.math.BigInteger;

class A {

static final String alpha = new String("1023456789abcdefghijklmnopqrstv");


public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int cases = in.nextInt(); in.nextLine();
for(int i=1;i<=cases;i++) { // FOR EACH CASE ....
String l = in.nextLine();
int next=0,k;
String out = new String();
for(int j=0;j<l.length();j++) {
char ch = l.charAt(j);
if((k=l.substring(0,j).indexOf(ch))>-1) out+=out.charAt(k); // repeated
else out+=alpha.charAt(next++); // new digit
}
System.out.println("Case #"+i+": "+new BigInteger(out,next>1?next:2));
}
}
}

You might also like