java ACM 大數相加使用的bigInteger

package com.test;

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
  BigInteger a, b;
  int t;
  Scanner sca = new Scanner(System.in);
  while (sca.hasNextBigInteger()) {
   t = sca.nextInt();
   for (int i = 1; i <=t; i++) {
    a = sca.nextBigInteger();
    b = sca.nextBigInteger();
    System.out.println("Case " + i + ":");
    System.out.println(a + " + " + b + " = " + a.add(b) + "\n");
   }
  }
 }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章