题解 | #尼科彻斯定理#

尼科彻斯定理

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

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m=in.nextInt();
        for(int i=1;i<1000000;i+=2){
            if((i+i+2*(m-1))*m/2==Math.pow(m,3)){
                System.out.print(i);
                for(int j=1;j<m;j++){
                    System.out.print("+"+(i+j*2));
                }
                break;
            }
        }
    }
}

全部评论

相关推荐

07-21 12:41
已编辑
门头沟学院 Java
steelhead:不是你的问题,这是社会的问题。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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