題目
在有些方面,比如大整數的處理,不得不佩服Java,好用沒的說,像開掛一樣
題解 Java
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 總行數
int total = Integer.parseInt(sc.nextLine());
// 兩數相加 與第三個數比較
for (int i = 0; i < total; i++) {
String str = sc.nextLine();
String[] strArr = str.split(" ");
BigInteger big1 = new BigInteger(strArr[0]);
BigInteger big2 = new BigInteger(strArr[1]);
BigInteger big3 = new BigInteger(strArr[2]);
BigInteger sum = big1.add(big2);
if (sum.compareTo(big3) > 0) {// sum>big3
System.out.println("Case #" + (i + 1) + ": true");
} else {
System.out.println("Case #" + (i + 1) + ": false");
}
}
}
}