题解 | #尼科彻斯定理#

尼科彻斯定理

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

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();
            String[] strs = new String[n];
            int k = n*n-n+1;
            int j = 0;
            for (int i = 0; i < n; i++)
            {
                strs[i] = String.valueOf(k+j);
                j+=2;
            }
            System.out.println(String.join("+",strs));
        }
    }
}

#利用数学公式推算的#
全部评论

相关推荐

07-11 13:16
湖南工学院 Java
点赞 评论 收藏
分享
机械打工仔:有说的你怀疑一下就行了,直接问也太实诚了
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-11 15:08
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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