题解 | #尼科彻斯定理#

尼科彻斯定理

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import static java.util.stream.Stream.*;


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

        //testCompletePack();
        testTh();
    }

    private static void testTh() throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while ((str = bf.readLine()) != null) {
            int parseInt = Integer.parseInt(str);
            double pow = Math.pow(parseInt, 3);
            int res = 0;
            int i = 1;
            int temp = 1;
            String te = "";
            while (res != pow) {
                res = 0;
                StringJoiner sj = new StringJoiner("+");
                for (int j = 1; j <= parseInt ; j++) {
                    res = i + res;
                    sj.add(i + "");
                    i = i + 2;
                }
                temp = temp + 2;
                i = temp;
                te = sj.toString();
            }
            System.out.println(te);



        }

    }




}

全部评论

相关推荐

10-15 20:01
已编辑
上海大学 Java
钉钉什么垃圾公司,约面鸽人
光年在眼前:不是坏事,感觉钉钉挺逆天的,二面结束还给我留作业,让我使用钉钉和看最新的发布会,然后说感受,我是应该不会去,三面直接拒绝不面了
点赞 评论 收藏
分享
用微笑面对困难:只要你保证项目和获奖都是真的就行尤其是“对战,总负责人”啊这些套职,基本上队员,打杂的都这么写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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