题解 | #尼科彻斯定理#
尼科彻斯定理
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);
}
}
}
查看8道真题和解析