結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,632 KB
testcase_01 AC 3 ms
7,520 KB
testcase_02 AC 2 ms
7,368 KB
testcase_03 AC 3 ms
7,524 KB
testcase_04 AC 3 ms
7,772 KB
testcase_05 AC 2 ms
7,524 KB
testcase_06 AC 2 ms
7,520 KB
testcase_07 AC 3 ms
7,392 KB
testcase_08 AC 2 ms
7,524 KB
testcase_09 AC 2 ms
7,648 KB
testcase_10 AC 2 ms
7,516 KB
testcase_11 AC 2 ms
7,520 KB
testcase_12 AC 3 ms
7,652 KB
testcase_13 AC 12 ms
10,320 KB
testcase_14 AC 14 ms
10,616 KB
testcase_15 AC 17 ms
10,848 KB
testcase_16 AC 17 ms
11,176 KB
testcase_17 AC 17 ms
11,504 KB
testcase_18 AC 15 ms
10,960 KB
testcase_19 AC 22 ms
13,092 KB
testcase_20 AC 8 ms
8,844 KB
testcase_21 AC 7 ms
8,860 KB
testcase_22 AC 3 ms
7,564 KB
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

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][201][1801];
ll dp2[2][201][1801];

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