Problem - 1013 (hdu.edu.cn)
高精度算术模拟
开long没过想到开bI 开bl一次过
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); BigInteger i; while (!(i = sc.nextBigInteger()).equals(BigInteger.ZERO)) { BigInteger sum = BigInteger.ZERO; while (i.compareTo(BigInteger.ZERO) > 0) { sum = sum.add(i.mod(BigInteger.TEN)); i = i.divide(BigInteger.TEN); } while (sum.compareTo(BigInteger.TEN) >= 0) { i = sum; sum = BigInteger.ZERO; while (i.compareTo(BigInteger.ZERO) > 0) { sum = sum.add(i.mod(BigInteger.TEN)); i = i.divide(BigInteger.TEN); } } System.out.println(sum); } } }