結果

問題 No.189 SUPER HAPPY DAY
ユーザー h_nosonh_noson
提出日時 2016-06-08 14:22:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 1,572 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 67,024 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2024-04-17 09:43:03
合計ジャッジ時間 1,509 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 11 ms
7,808 KB
testcase_14 AC 15 ms
9,344 KB
testcase_15 AC 16 ms
8,704 KB
testcase_16 AC 19 ms
9,088 KB
testcase_17 AC 19 ms
9,728 KB
testcase_18 AC 16 ms
8,320 KB
testcase_19 AC 20 ms
11,392 KB
testcase_20 AC 7 ms
5,888 KB
testcase_21 AC 7 ms
5,888 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 18 ms
9,088 KB
testcase_24 AC 20 ms
9,216 KB
testcase_25 AC 32 ms
14,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD (int)(1e9+9)

typedef long long ll;

ll dp[2][202][1810];
ll dp2[2][202][1810];

int main(void) {
    int i, j, k;
    string m, d;
    cin >> m >> d;
    dp[1][0][0] = 1;
    rep (i,m.size()) {
        rep (j,m.size() * 9 + 1) {
            rep (k,10) {
                if (k == m[i] - '0') {
                    dp[1][i+1][j+k] += dp[1][i][j];
                    dp[1][i+1][j+k] %= MOD;
                }
                dp[0][i+1][j+k] += dp[0][i][j];
                if (k < m[i] - '0')
                    dp[0][i+1][j+k] += dp[1][i][j];
                dp[0][i+1][j+k] %= MOD;
            }
        }
    }
    dp2[1][0][0] = 1;
    rep (i,d.size()) {
        rep (j,d.size() * 9 + 1) {
            rep (k,10) {
                if (k == d[i] - '0') {
                    dp2[1][i+1][j+k] += dp2[1][i][j];
                    dp2[1][i+1][j+k] %= MOD;
                }
                dp2[0][i+1][j+k] += dp2[0][i][j];
                if (k < d[i] - '0')
                    dp2[0][i+1][j+k] += dp2[1][i][j];
                dp2[0][i+1][j+k] %= MOD;
            }
        }
    }
    int ans = 0;
    REP (j,1,1800)
        ans = (ans + (dp[0][m.size()][j]+dp[1][m.size()][j]) * (dp2[0][d.size()][j]+dp2[1][d.size()][j])) % MOD;
    cout << ans << endl;
    return 0;
}
0