题目地址:http://poj.org/problem?id=1894
import java.util.*;
import java.math.*;
import java.text.*;
import java.io.*;public class Main
{public static void main(String[] args) {Scanner cin = new Scanner(new BufferedInputStream(System.in));int base=cin.nextInt();BigInteger n=cin.nextBigInteger();String ans = new String();while(n.compareTo(BigInteger.ZERO)!=0){if(n.mod(BigInteger.valueOf(base)).compareTo(BigInteger.ZERO)==0){ans=base+ans;n=n.divide(BigInteger.valueOf(base)).subtract(BigInteger.ONE);}else {ans=n.mod(BigInteger.valueOf(base))+ans;n=n.divide(BigInteger.valueOf(base));}}System.out.println(ans);}
}