题意:输出a+b = ?,但a, b可达1000位。
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002
——>>早早知道Java处理大整数问题非常非常非非常方便,今天一试,果然……
import java.util.Scanner; import java.math.BigInteger; public class Main { public static void main(String[] args) { int T, cnt = 1; Scanner cin = new Scanner(System.in); T = cin.nextInt(); while(T-->0){ String s1 = cin.next(); String s2 = cin.next(); BigInteger a = new BigInteger(s1); BigInteger b = new BigInteger(s2); System.out.println("Case " + (cnt++) + ":"); System.out.println(a + " + " + b + " = " + a.add(b)); if(T > 0) System.out.println(); } cin.close(); } }