题解 | #等差数列#

等差数列

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

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int n = sc.nextInt();
            int sum = 0;
            for (int i = 2; i < 2+(n*3); i=i+3) {
                sum +=i;
            }
            System.out.println(sum);
        }
    }
}

全部评论

相关推荐

bangbangba...:感觉三个项目可以融在一起,比如上层是用手写的epoll,然后到tcp聊天层,然后你写了一个后台监控(不过我也不懂c++,但是感觉写一个大项目比三个小项目要好)
我的求职进度条
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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