結果

問題 No.189 SUPER HAPPY DAY
ユーザー lapilapi
提出日時 2020-02-17 16:12:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 1,590 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 109,036 KB
実行使用メモリ 14,720 KB
最終ジャッジ日時 2024-04-16 03:50:33
合計ジャッジ時間 2,106 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 21 ms
8,960 KB
testcase_14 AC 28 ms
10,240 KB
testcase_15 AC 23 ms
9,216 KB
testcase_16 AC 23 ms
9,344 KB
testcase_17 AC 28 ms
10,624 KB
testcase_18 AC 21 ms
9,216 KB
testcase_19 AC 32 ms
11,648 KB
testcase_20 AC 14 ms
6,528 KB
testcase_21 AC 16 ms
7,296 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 18 ms
9,344 KB
testcase_24 AC 18 ms
9,088 KB
testcase_25 AC 34 ms
14,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000009 // 10^9 + 9
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

ll A[209], B[209];

ll dp1[209][2][1809];
ll dp2[209][2][1809];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S, T; cin >> S >> T;
	for (int i = 0; i < S.size(); i++) A[i] = S[i] - '0';
	for (int i = 0; i < T.size(); i++) B[i] = T[i] - '0';

	dp1[0][0][0] = dp2[0][0][0] = 1LL;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k <= 1800; k++) {
				for (int l = 0; l <= (j ? 9 : A[i]); l++) {
					if (k + l <= 1800) {
						dp1[i + 1][j || (l < A[i])][k + l] += dp1[i][j][k];
						dp1[i + 1][j || (l < A[i])][k + l] %= MOD;
					}
				}
			}
		}
	}

	for (int i = 0; i < T.size(); i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k <= 1800; k++) {
				for (int l = 0; l <= (j ? 9 : B[i]); l++) {
					if (k + l <= 1800) {
						dp2[i + 1][j || (l < B[i])][k + l] += dp2[i][j][k];
						dp2[i + 1][j || (l < B[i])][k + l] %= MOD;
					}
				}
			}
		}
	}

	ll ans = 0;
	for (int i = 1; i <= 1800; i++) {
		ans += ((dp1[S.size()][0][i] + dp1[S.size()][1][i]) % MOD) * ((dp2[T.size()][0][i] + dp2[T.size()][1][i]) % MOD);
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}
0