题解 | #尼科彻斯定理#
尼科彻斯定理
https://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextLine()) {
String nextLine = in.nextLine();
if (Objects.isNull(nextLine) || nextLine.equals("")) {
break;
}
int n = Integer.parseInt(nextLine);
List<String> calc = new ArrayList<>();
int n1 = n * (n - 1) + 1;
calc.add(n1 + "");
for (int i = 1; i < n; i++) {
calc.add(n1 + 2 * i + "");
}
System.out.println(String.join("+", calc));
}
}
}
查看12道真题和解析