結果

問題 No.189 SUPER HAPPY DAY
ユーザー Mail_TegamiMail_Tegami
提出日時 2022-10-11 20:18:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,195 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 61,100 KB
実行使用メモリ 131,788 KB
最終ジャッジ日時 2023-09-07 21:15:11
合計ジャッジ時間 3,002 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
131,604 KB
testcase_01 AC 37 ms
131,488 KB
testcase_02 AC 39 ms
131,480 KB
testcase_03 AC 35 ms
131,584 KB
testcase_04 AC 34 ms
131,512 KB
testcase_05 AC 38 ms
131,476 KB
testcase_06 AC 36 ms
131,504 KB
testcase_07 AC 36 ms
131,552 KB
testcase_08 AC 36 ms
131,584 KB
testcase_09 AC 36 ms
131,492 KB
testcase_10 AC 36 ms
131,604 KB
testcase_11 AC 36 ms
131,784 KB
testcase_12 AC 37 ms
131,600 KB
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 51 ms
131,512 KB
testcase_24 AC 48 ms
131,788 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <cstring>
#include <vector>
using namespace std;

const int MOD = 1e9 + 9;

long long dp[205][2][20005];
long long dp1[205][2][20005];

int main() {
	memset(dp, 0, sizeof(dp));
	memset(dp1, 0, sizeof(dp1));

	string M, D;
	cin >> M >> D;

	dp[0][0][0] = 1;

	int ML = M.size();
	int MAX = ML * 10;
	for (int i = 0; i < ML; i++)
	{
		int Mi = M[i] - '0';
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < MAX; k++)
			{
				for (int d = 0; d <= (j ? 9 : Mi); d++)
				{
					dp[i + 1][j||(d<Mi)][k + d] += dp[i][j][k];
				}
			}
		}
	}



	dp1[0][0][0] = 1;

	int DL = D.size();
	MAX = DL * 10;
	for (int i = 0; i < DL; i++)
	{
		int Di = D[i] - '0';
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < MAX; k++)
			{
				for (int d = 0; d <= (j ? 9 : Di); d++)
				{
					dp1[i + 1][j || (d < Di)][k + d] += dp1[i][j][k];
				}
			}
		}
	}

	long long ans =0LL;
	for (int i = 1; i < MAX; i++)
	{
		long long m = (dp[ML][0][i] + dp[ML][1][i]);
		long long d = (dp1[DL][0][i] + dp1[DL][1][i]);
		ans += m * d;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}
0