x 进制 的 z 转换成 y 进制


```java
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
    public static void main(String args[]) throws Exception {
    	
        Scanner cin=new Scanner(System.in);
        
        BigInteger x=cin.nextBigInteger();
        
        BigInteger y=cin.nextBigInteger();
        
        String z=cin.next();
        
		BigInteger bas=new BigInteger("1"),ans=new BigInteger("0");
		
        for(int i=z.length()-1;i>=0;i=i-1){
            char c=z.charAt(i);
        	ans=ans.add(bas.multiply(calu(c)));//System.out.println(calu(c));System.out.println(c);
        	bas=bas.multiply(x);
        }
        
        char a[]=new char [200100];
        //System.out.println(ans);
        //System.out.println(x);System.out.println(y);
        int cnt=0;
        BigInteger zo=new BigInteger("0");
        for(;;){
        	cnt=cnt+1;
        	a[cnt]=change(ans.mod(y));
        	
        	ans=ans.divide(y);
        	if(ans.compareTo(zo)==0){
        		break;
        	}
        }
        for(int i=cnt;i>=1;i--){
        	System.out.print(a[i]);
        }
        
    }

	private static char change(BigInteger mod) {
		// TODO Auto-generated method stub
		BigInteger zo=new BigInteger("0"),on=new BigInteger("1");
		BigInteger i = new BigInteger("0");
		char k='0';
		for(;k<='9';i=i.add(on)){
			if(i.compareTo(mod)==0) return k;
			k++; 
		}
		k='A';
		for(;k<='Z';i=i.add(on)){
			if(i.compareTo(mod)==0) return k;
			k++; 
		}
		k='a';
		for(;k<='z';i=i.add(on)){
			if(i.compareTo(mod)==0) return k;
			k++; 
		}
		return k;
		
	}

	private static BigInteger calu(char c) {
		// TODO Auto-generated method stub
		char m='0';  BigInteger w=new BigInteger("1");
		
		int k=0;
		for(BigInteger i=new BigInteger("0");k<=9;i=i.add(w)){
			if(m==c) return i;
			m++;k++;
		}
		k=1;m='A';
		for(BigInteger i=new BigInteger("10");k<=26;i=i.add(w)){
			//System.out.println(i);
			if(m==c) {return i;}
			m++;k++;
		}
		
		k=1;m='a';
		for(BigInteger i=new BigInteger("36");k<=26;i=i.add(w)){
			if(m==c) return i;
			m++;k++;
		}
		return w;
	}
}