题解 | HJ76 #尼科彻斯定理#
尼科彻斯定理
https://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); int sum = (int)Math.pow(num, 3); // System.out.println(pow); int a = num * num + 1 - num; StringBuilder builder = new StringBuilder(); for (int i = 0; i < num; i++) { builder.append(a); builder.append("+"); a += 2; } builder.deleteCharAt(builder.length() - 1); System.out.println(builder); } }
等差数列给定和与项数求首项值