結果

問題 No.189 SUPER HAPPY DAY
ユーザー pekempeypekempey
提出日時 2015-08-12 16:43:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 1,251 bytes
コンパイル時間 1,315 ms
コンパイル使用メモリ 146,364 KB
実行使用メモリ 16,344 KB
最終ジャッジ日時 2023-09-25 08:29:13
合計ジャッジ時間 2,859 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,508 KB
testcase_01 AC 4 ms
5,624 KB
testcase_02 AC 3 ms
5,440 KB
testcase_03 AC 4 ms
5,624 KB
testcase_04 AC 3 ms
5,836 KB
testcase_05 AC 4 ms
5,608 KB
testcase_06 AC 3 ms
5,576 KB
testcase_07 AC 3 ms
5,640 KB
testcase_08 AC 3 ms
5,616 KB
testcase_09 AC 4 ms
5,592 KB
testcase_10 AC 3 ms
5,588 KB
testcase_11 AC 4 ms
5,600 KB
testcase_12 AC 3 ms
5,592 KB
testcase_13 AC 31 ms
9,844 KB
testcase_14 AC 38 ms
11,396 KB
testcase_15 AC 34 ms
11,104 KB
testcase_16 AC 35 ms
11,520 KB
testcase_17 AC 40 ms
11,620 KB
testcase_18 AC 33 ms
10,944 KB
testcase_19 AC 48 ms
12,964 KB
testcase_20 AC 18 ms
7,248 KB
testcase_21 AC 23 ms
8,240 KB
testcase_22 AC 7 ms
6,420 KB
testcase_23 AC 27 ms
11,584 KB
testcase_24 AC 25 ms
10,168 KB
testcase_25 AC 50 ms
16,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 9;

ll dp1[205][2030][2]; // pos, sum, less
ll dp2[205][2030][2]; // pos, sum, less

void calc(ll dp[205][2030][2], string s) {
    dp[0][0][0] = 1;

    rep (i, s.length()) {
        rep (j, 2020) {
            rep (k, 2) {
                int ub;
                if (k) {
                    ub = 9;
                } else {
                    ub = s[i] - '0';
                }

                rep (l, ub + 1) {
                    (dp[i + 1][j + l][k || l < ub] += dp[i][j][k]) %= mod;
                }
            }
        }
    }
}

int main() {
    string M, D;
    cin >> M >> D;

    calc(dp1, M);
    calc(dp2, D);

    rep (j, 2020) {
        dp1[M.length()][j][0] += dp1[M.length()][j][1];
        dp2[D.length()][j][0] += dp2[D.length()][j][1];
    }

    ll ans = 0;

    rep2 (i, 1, 2020) {
        ans += dp1[M.length()][i][0] * dp2[D.length()][i][0];
        ans %= mod;
    }

    cout << ans << endl;
}
0