import java.math.BigInteger;
import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
while(scan.hasNext())
{
int M=scan.nextInt();//M和N可以根据题目要求改
int N=scan.nextInt();
String val = scan.next();
//next忽略空格,enter,tab直到发现有效的输入
//nextLine会将Enter之前字符作为输入//进制转化出来的BigInteger要 new出来,其他的不需要直接BigInteger.就行了
BigInteger big=new BigInteger(val, M);//得到M进制转化为十进制后的BigInteger!!!这个时候BigInteger已经是十进制了
//必须这样写用new创建实例,不能把下面的big代替为一次性的BigInteger
String ans = big.toString(N).toLowerCase();//根据题目要求调整大小写//这个默认是小写的
System.out.println(ans);
}
}
}
第一种题目,十六进制给你的是ox开头的,使用.substring(begin) (其实这个还有substring(begin,end))
String val = scan.next().substring(2);
第二种题目
输出的字母的格式有要求,在最后加一个toUpperCase或者toLowerCase就行了
没啥好说的,BigInteger赛高