题解 | #等差数列#
等差数列
http://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
都是直接用公式吧
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
System.out.println(n*2+n*(n-1)/2*3);
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
System.out.println(n*2+n*(n-1)/2*3);
}
}