题解 | #Integer Inquiry#

Integer Inquiry

https://www.nowcoder.com/practice/df03906024d742cc919a64c22983f5e1

import java.util.Scanner;
import java.math.BigInteger;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // ArrayList<BigInteger> list = new ArrayList<BigInteger>;
        BigInteger b = BigInteger.valueOf(0);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextBigInteger()) { // 注意 while 处理多个 case
            BigInteger a = in.nextBigInteger();
            if(a.equals(BigInteger.valueOf(0)))break;
            b = b.add(a);
        }
        System.out.println(b);
    }
}

真是jaja又vava啊

全部评论

相关推荐

02-26 16:52
门头沟学院 Java
Lunarloop:董事长亲自到ssob来要IM项目的技术方案来了
点赞 评论 收藏
分享
03-07 17:32
已编辑
中南大学 C++
是只吗喽:淘天和米哈游之间只隔了15分钟,有点极限了xd
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务