結果

問題 No.220 世界のなんとか2
ユーザー yui_cute__yui_cute__
提出日時 2020-06-10 00:07:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 980 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 172,096 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-01 22:59:46
合計ジャッジ時間 3,069 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int p;
    cin >> p;
    vector<vector<vector<ll>>> dp(p + 1, vector<vector<ll>>(2, vector<ll>(3)));
    dp[0][0][0] = 1;
    for(int i = 0; i < p; i++){
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < 3; k++){
                for(int n = 0; n <= 9; n++){
                    dp[i + 1][j || (n == 3)][(k + n) % 3] += dp[i][j][k];
                }
            }
        }
    }
    /*for(int i = 0; i <= p; i++){
        cout << "\n";
        for(int j = 0; j < 2; j++){
            cout << "\n";
            for(int k = 0; k < 3; k++){
                cout <<  dp[i][j][k] << " ";
            }
        }
    }*/
    cout << dp[p][0][0] + dp[p][1][0] + dp[p][1][1] + dp[p][1][2] - 1 << "\n";
}
0