結果

問題 No.189 SUPER HAPPY DAY
ユーザー なおなお
提出日時 2015-04-22 01:42:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 964 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 144,976 KB
実行使用メモリ 17,480 KB
最終ジャッジ日時 2023-09-18 07:37:50
合計ジャッジ時間 2,850 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
17,188 KB
testcase_01 AC 8 ms
17,344 KB
testcase_02 AC 7 ms
17,208 KB
testcase_03 AC 8 ms
17,196 KB
testcase_04 AC 8 ms
17,188 KB
testcase_05 AC 7 ms
17,168 KB
testcase_06 AC 7 ms
17,216 KB
testcase_07 AC 8 ms
17,200 KB
testcase_08 AC 8 ms
17,248 KB
testcase_09 AC 9 ms
17,288 KB
testcase_10 AC 8 ms
17,348 KB
testcase_11 AC 9 ms
17,236 KB
testcase_12 AC 8 ms
17,168 KB
testcase_13 AC 47 ms
17,196 KB
testcase_14 AC 59 ms
17,472 KB
testcase_15 AC 51 ms
17,204 KB
testcase_16 AC 50 ms
17,264 KB
testcase_17 AC 59 ms
17,184 KB
testcase_18 AC 47 ms
17,232 KB
testcase_19 AC 70 ms
17,256 KB
testcase_20 AC 29 ms
17,272 KB
testcase_21 AC 36 ms
17,220 KB
testcase_22 AC 14 ms
17,188 KB
testcase_23 AC 38 ms
17,252 KB
testcase_24 AC 38 ms
17,228 KB
testcase_25 AC 69 ms
17,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
#define FOR(i, f, t)        for(int(i)=(f);(i)<(t);(++i))
const int MOD = int(1e9+9);

ll dp1[2000][222][2], dp2[2000][222][2];
string M,D;

ll dfs( ll (*dp)[222][2], const string &v, const int s, const int i, const bool f){
    if(s < 0) return 0;
    if(i == v.size()) return (s == 0)?1:0;
    if(dp[s][i][f] >= 0) return dp[s][i][f];
    int d = v[i]-'0';
    ll res = 0;
    if(f) REP(j,d+1) (res += dfs(dp, v, s-j, i+1, j==d)) %= MOD;
    else  REP(j,10) (res += dfs(dp, v, s-j, i+1, 0)) %= MOD;
    return (dp[s][i][f] = res);
}

int main(){
    do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0);
    memset(dp1,-1,sizeof(dp1));
    memset(dp2,-1,sizeof(dp2));
    cin >> M >> D;
    ll res = 0;
    FOR(i,1,2000) (res += dfs(dp1, M, i, 0, 1) * dfs(dp2, D, i, 0, 1) % MOD) %= MOD;
    cout << res << endl;
    return 0;
}
0