题解 | #尼科彻斯定理#
尼科彻斯定理
https://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85
目测最简洁!
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int n = in.nextInt(); int[] arr = new int[n]; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++){ arr[i] = n*(n-1)+1+i*2; sb.append("+" + arr[i]); } System.out.print(sb.substring(1)); } } }