HDOJ2101 A + B Problem Too
阿新 • • 發佈:2019-02-16
題意:A+B的和能整除86,但是沒說明A,B的範圍,使用大數來解
下面AC程式碼:
import java.math.BigDecimal; import java.util.Scanner; public class Main{ private static Scanner scanner; public static void main(String[] args) { scanner = new Scanner(System.in); while (scanner.hasNext()) { String aString = scanner.next(); String bString = scanner.next(); BigDecimal aDecimal = new BigDecimal(aString); BigDecimal bDecimal = new BigDecimal(bString); BigDecimal sumDecimal = aDecimal.add(bDecimal); if (sumDecimal.divideAndRemainder(new BigDecimal(86))[1].equals(new BigDecimal(0))) { System.out.println("yes"); } else { System.out.println("no"); } } } }