HDU2057 A+B Again

才发现BigInteger可以进行32进制内的任意转换,真好用

import java.math.BigInteger;
import java.util.Scanner;
	
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext()) {
			 String a=in.next();
			 String b=in.next();
			 BigInteger aa=new BigInteger(a,16);
			 BigInteger bb=new BigInteger(b,16);
			 BigInteger c=aa.add(bb);
			 String c1=c.toString(16);
			 System.out.println(c1.toUpperCase());
		}
	}

}

 

你可能感兴趣的:(HDU2057 A+B Again)