【PAT甲级 大整数BigInteger】1065 A+B and C (64bit) (20 分) Java 全部AC
生活随笔
收集整理的這篇文章主要介紹了
【PAT甲级 大整数BigInteger】1065 A+B and C (64bit) (20 分) Java 全部AC
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
題目
在有些方面,比如大整數(shù)的處理,不得不佩服Java,好用沒(méi)的說(shuō),像開(kāi)掛一樣
題解 Java
import java.math.BigInteger; import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);// 總行數(shù)int total = Integer.parseInt(sc.nextLine());// 兩數(shù)相加 與第三個(gè)數(shù)比較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>big3System.out.println("Case #" + (i + 1) + ": true");} else {System.out.println("Case #" + (i + 1) + ": false");}}} }總結(jié)
以上是生活随笔為你收集整理的【PAT甲级 大整数BigInteger】1065 A+B and C (64bit) (20 分) Java 全部AC的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【PAT甲级 约会】1061 Datin
- 下一篇: 【PAT甲级 前导0,排序】1069 T