题解 | #尼科彻斯定理#

尼科彻斯定理

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

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int total = m * m * m;
        for (int i = 1; i <= total; i++) {
            if (i % 2 != 0 && (2 * (m - 1) + i + i) * m * 0.5 == total) {
                for (int j = 0; j < m - 1; j++) {
                    System.out.print(i + "+");
                    i = i + 2;
                }
                System.out.print(i);
                break;
            }
        }
    }
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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