結果

問題 No.1824 門\松\列
ユーザー ks2mks2m
提出日時 2022-01-28 22:29:46
言語 Java
(openjdk 23)
結果
AC  
実行時間 365 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 2,811 ms
コンパイル使用メモリ 74,344 KB
実行使用メモリ 54,956 KB
最終ジャッジ日時 2024-12-30 08:24:55
合計ジャッジ時間 4,835 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int t= sc.nextInt();

		long[] x = new long[1000001];
		for (int i = 1; i < x.length; i++) {
			x[i] = (long) i * (i + 1) + x[i - 1];
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int z = 0; z < t; z++) {
			int n = sc.nextInt();

			pw.println(x[n - 2] * 2);
		}
		pw.flush();
		sc.close();
	}
}
0