結果

問題 No.189 SUPER HAPPY DAY
ユーザー koyoprokoyopro
提出日時 2020-03-24 00:43:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 1,492 bytes
コンパイル時間 1,397 ms
コンパイル使用メモリ 146,352 KB
実行使用メモリ 9,568 KB
最終ジャッジ日時 2023-08-28 16:39:27
合計ジャッジ時間 2,574 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,496 KB
testcase_01 AC 2 ms
5,504 KB
testcase_02 AC 2 ms
5,428 KB
testcase_03 AC 2 ms
5,528 KB
testcase_04 AC 2 ms
5,500 KB
testcase_05 AC 2 ms
5,472 KB
testcase_06 AC 2 ms
5,612 KB
testcase_07 AC 2 ms
5,496 KB
testcase_08 AC 2 ms
5,488 KB
testcase_09 AC 2 ms
5,544 KB
testcase_10 AC 2 ms
5,472 KB
testcase_11 AC 2 ms
5,488 KB
testcase_12 AC 2 ms
5,536 KB
testcase_13 AC 16 ms
7,544 KB
testcase_14 AC 21 ms
8,236 KB
testcase_15 AC 23 ms
8,072 KB
testcase_16 AC 26 ms
8,604 KB
testcase_17 AC 27 ms
6,752 KB
testcase_18 AC 21 ms
8,064 KB
testcase_19 AC 29 ms
9,372 KB
testcase_20 AC 10 ms
6,676 KB
testcase_21 AC 9 ms
6,920 KB
testcase_22 AC 3 ms
5,688 KB
testcase_23 AC 26 ms
8,544 KB
testcase_24 AC 27 ms
6,492 KB
testcase_25 AC 51 ms
9,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
string M,D;
// MorD, i桁目まで見て, 未満(1)かどうか, 桁の数値合計 → 組み合わせ数
int DP[2][222][2][2222];
int MOD=1000000009;

void dp(int a, string s) {
    DP[a][0][0][0] = 1;
    REP(i,s.size())REP(j,2)REP(k,2222) {
        if (!DP[a][i][j][k]) continue;
        int n = j ? 9 : s[i]-'0';
        REP(l,n+1) {
            (DP[a][i+1][j||l<n][k+l] += DP[a][i][j][k]) %= MOD;
        }
    }
}

void solve() {
    cin>>M>>D;
    dp(0,M);
    dp(1,D);
    int ans = 0;
    REP(i,2222) {
        ans += (DP[0][M.size()][0][i]+DP[0][M.size()][1][i])*(DP[1][D.size()][0][i]+DP[1][D.size()][1][i]);
        ans %= MOD;
    }
    cout << ((ans-1+MOD)%MOD) << endl;
}
0