結果

問題 No.1824 門\松\列
ユーザー horoyoisawahoroyoisawa
提出日時 2022-01-29 10:10:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 3,530 ms
コンパイル使用メモリ 164,164 KB
実行使用メモリ 10,816 KB
最終ジャッジ日時 2023-08-30 07:22:05
合計ジャッジ時間 2,288 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
10,716 KB
testcase_01 AC 6 ms
10,744 KB
testcase_02 AC 7 ms
10,816 KB
testcase_03 AC 22 ms
10,744 KB
testcase_04 AC 7 ms
10,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int t;
    cin >> t;
    vector<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