結果

問題 No.220 世界のなんとか2
ユーザー maine_honzukimaine_honzuki
提出日時 2020-12-25 00:51:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 561 bytes
コンパイル時間 2,004 ms
コンパイル使用メモリ 203,516 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 16:01:43
合計ジャッジ時間 2,647 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int P;
    cin >> P;
    vector<ll> now(4);
    now[0] = 1;
    while (P--) {
        vector<ll> nxt(4);
        for (int i = 0; i < 10; i++) {
            if (i == 3)
                nxt[3] += accumulate(now.begin(), now.begin() + 3, 0ll);
            else
                for (int j = 0; j < 3; j++)
                    nxt[(j + i) % 3] += now[j];
        }
        nxt[3] += now[3] * 10;
        swap(now, nxt);
    }
    now[0]--;

    cout << now[0] + now[3] << endl;
}
0