結果

問題 No.1824 門\松\列
ユーザー horoyoisawahoroyoisawa
提出日時 2022-01-29 10:24:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 1,503 ms
コンパイル使用メモリ 163,740 KB
実行使用メモリ 11,432 KB
最終ジャッジ日時 2023-08-30 07:37:26
合計ジャッジ時間 2,029 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,144 KB
testcase_01 AC 5 ms
11,432 KB
testcase_02 AC 6 ms
11,168 KB
testcase_03 AC 21 ms
11,184 KB
testcase_04 AC 7 ms
11,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    long long out[1000001];
    out[3] = 4;
    for(int i=4;i<1000001;i++) {
        long long p = (long long)(i - 1) * (i - 2);
        // q = (1 + 2 + 3 + ... + i - 2) * 2
        long long q = (long long)(i - 1) * (i - 2);
        out[i] = out[i-1] + p + q;
    }

    for(int i=0;i<t;i++) {
        int n;
        cin >> n;
        cout << out[n] << endl;
    }

    return 0;
}
0