結果

問題 No.189 SUPER HAPPY DAY
ユーザー Mail_TegamiMail_Tegami
提出日時 2022-10-11 20:12:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,133 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 62,448 KB
実行使用メモリ 16,108 KB
最終ジャッジ日時 2023-09-07 21:10:36
合計ジャッジ時間 1,986 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,424 KB
testcase_01 AC 2 ms
5,600 KB
testcase_02 AC 2 ms
5,412 KB
testcase_03 AC 2 ms
5,476 KB
testcase_04 AC 2 ms
5,500 KB
testcase_05 AC 2 ms
5,460 KB
testcase_06 AC 2 ms
5,456 KB
testcase_07 AC 2 ms
5,500 KB
testcase_08 AC 2 ms
5,604 KB
testcase_09 AC 2 ms
5,452 KB
testcase_10 AC 2 ms
5,472 KB
testcase_11 AC 2 ms
5,456 KB
testcase_12 AC 2 ms
5,472 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 WA -
testcase_24 WA -
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][2005];
long long dp1[205][2][2005];

int main() {

	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