結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 3 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 3 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 3 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 18 ms
9,344 KB
testcase_24 AC 18 ms
9,216 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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 1000000007 // 10^9 + 7
#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