結果

問題 No.189 SUPER HAPPY DAY
ユーザー airisairis
提出日時 2015-06-07 22:09:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 1,915 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 77,464 KB
実行使用メモリ 14,692 KB
最終ジャッジ日時 2023-09-20 19:40:36
合計ジャッジ時間 1,911 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,432 KB
testcase_01 AC 4 ms
5,600 KB
testcase_02 AC 2 ms
5,544 KB
testcase_03 AC 3 ms
5,504 KB
testcase_04 AC 3 ms
5,496 KB
testcase_05 AC 3 ms
5,620 KB
testcase_06 AC 3 ms
5,592 KB
testcase_07 AC 3 ms
5,532 KB
testcase_08 AC 3 ms
5,608 KB
testcase_09 AC 4 ms
5,820 KB
testcase_10 AC 3 ms
5,560 KB
testcase_11 AC 3 ms
5,584 KB
testcase_12 AC 3 ms
5,564 KB
testcase_13 AC 21 ms
9,812 KB
testcase_14 AC 28 ms
11,856 KB
testcase_15 AC 25 ms
10,792 KB
testcase_16 AC 26 ms
11,388 KB
testcase_17 AC 29 ms
10,352 KB
testcase_18 AC 24 ms
10,656 KB
testcase_19 AC 34 ms
11,980 KB
testcase_20 AC 13 ms
7,880 KB
testcase_21 AC 16 ms
9,916 KB
testcase_22 AC 5 ms
5,980 KB
testcase_23 AC 19 ms
9,496 KB
testcase_24 AC 19 ms
9,016 KB
testcase_25 AC 37 ms
14,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <numeric>
#include <bitset>
#include <complex>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++)
#define EPS (1e-14)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;

const ll MOD = 1e+9 + 9;

string s, t;
ll dp[205][1805][2];
ll dp2[205][1805][2];
ll ans;

void solve() {
	dp[s.size()][0][0] = 1;
	dp[s.size()][0][1] = 1;
	for (int i = s.size() - 1; i >= 0; i--) {
		for (int j = 0; j <= 1800; j++) {
			for (int k = 0; k < 10; k++) {
				dp[i][j][0] += dp[i + 1][j - k][0];
				dp[i][j][0] %= MOD;
			}
			for (int k = 0; k <= j && k < s[i] - '0'; k++) {
				dp[i][j][1] += dp[i + 1][j - k][0];
				dp[i][j][1] %= MOD;
			}
			if (j - (s[i] - '0') >= 0) {
				dp[i][j][1] += dp[i + 1][j - (s[i] - '0')][1];
				dp[i][j][1] %= MOD;
			}
		}
	}
	dp2[t.size()][0][0] = 1;
	dp2[t.size()][0][1] = 1;
	for (int i = t.size() - 1; i >= 0; i--) {
		for (int j = 0; j <= 1800; j++) {
			for (int k = 0; k < 10; k++) {
				dp2[i][j][0] += dp2[i + 1][j - k][0];
				dp2[i][j][0] %= MOD;
			}
			for (int k = 0; k <= j && k < t[i] - '0'; k++) {
				dp2[i][j][1] += dp2[i + 1][j - k][0];
				dp2[i][j][1] %= MOD;
			}
			if (j - (t[i] - '0') >= 0) {
				dp2[i][j][1] += dp2[i + 1][j - (t[i] - '0')][1];
				dp2[i][j][1] %= MOD;
			}
		}
	}
#if 0
	rep(i, 101) {
		cout << i << ":" << dp[0][i][1] << endl;
	}
#else
	REP(i, 0, 1800 + 1) {
		ans += (dp[0][i][1] * dp2[0][i][1]) % MOD;
		ans %= MOD;
	}
	cout << ((ans-1) + MOD) % MOD << endl;
#endif
}

int main() {
	cin >> s >> t;
	solve();
	return 0;
}


0