题解 | #数列求和#

数列求和

https://www.nowcoder.com/practice/6893484c04c24bfca1f606b1823a468d

import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {

        //write your code here........
        StringJoiner joiner = new StringJoiner(",");
        String a = "";
        long total = 0L;
        for (long i = 1; i <= 10; i++) {
            a = "9" + a;
            joiner.add(a);
            //计算
            total = total + Long.valueOf(a);
        }
        //System.out.println(joiner.toString());
        System.out.println(total);

    }
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
2025-12-03 16:51
匿名牛油:小红书上孝子太多了,主包说华为开13膈应,有孝子竟对主包进行人身攻击,说主包能力不行所以开13,殊不知主包是优实,有多个竞赛国一。删帖了
点赞 评论 收藏
分享
2025-12-30 16:42
同济大学 C++
仁狂躁使者:哎呀,不用担心,我当时配环境配了两天,项目捋不清就问问导师能不能用ai,慢慢就清了,会好起来的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务