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

java
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)); } } }

Página 1 de 1

Sign up to vote on this title
UsefulNot useful