HDOJ 1013 Digital Roots
2017-10-13 20:17
323 查看
HDACM1013
大数解法
大数解法
import java.math.BigInteger; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { BigInteger n = sc.nextBigInteger(); if (n.compareTo(BigInteger.ZERO)==0) { break; } BigInteger sum = BigInteger.ZERO; while (n.compareTo(BigInteger.ZERO)!=0){ BigInteger temp = n.mod(BigInteger.TEN); sum = sum.add(temp); n=n.divide(BigInteger.TEN); if (n.compareTo(BigInteger.ZERO)==0) { if (sum.compareTo(BigInteger.TEN)==-1) { break; } n = sum; sum = BigInteger.ZERO; } } System.out.println(sum); } } }
相关文章推荐
- (HDOJ 1013)Digital Roots
- HDOJ 1013 Digital Roots
- HDOJ 1013 Digital Roots(大数)
- HDOJ 1013 Digital Roots
- hdoj1013_Digital Roots
- ACM--数字位数相加--HDOJ 1013--Digital Roots--水
- HDOJ1013 Digital Roots
- hdoj 1013 Digital Roots
- hdoj 1013 Digital Roots
- HDOJ 1013 Digital Roots
- HDOJ HDU 1013 Digital Roots
- 渣渣ACM日记——1013-Digital Roots (HDOJ)
- HDOJ1013 Digital Roots
- HDOJ1013 Digital Roots
- HDOJ(1013) ——Digital Roots(字符串模拟题)
- HDOJ1013 Digital Roots(高精度+数位分离求和)
- HDOJ1013【Digital Roots】
- HDOJ 1013 Digital Roots(算是大数水题)
- HDOJ 1013 Digital Roots
- hdoj 1013 Digital roots (陷阱水题)