結果

問題 No.189 SUPER HAPPY DAY
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-22 00:21:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,454 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 145,828 KB
実行使用メモリ 14,228 KB
最終ジャッジ日時 2023-09-18 03:39:58
合計ジャッジ時間 2,981 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,440 KB
testcase_01 AC 2 ms
5,536 KB
testcase_02 AC 2 ms
5,456 KB
testcase_03 AC 2 ms
5,716 KB
testcase_04 AC 2 ms
5,640 KB
testcase_05 AC 2 ms
5,468 KB
testcase_06 AC 2 ms
5,440 KB
testcase_07 AC 2 ms
5,452 KB
testcase_08 AC 2 ms
5,788 KB
testcase_09 AC 2 ms
5,572 KB
testcase_10 AC 2 ms
5,572 KB
testcase_11 AC 2 ms
5,456 KB
testcase_12 AC 2 ms
5,476 KB
testcase_13 AC 6 ms
10,112 KB
testcase_14 AC 8 ms
12,160 KB
testcase_15 AC 7 ms
10,080 KB
testcase_16 AC 8 ms
10,076 KB
testcase_17 AC 9 ms
10,084 KB
testcase_18 AC 7 ms
10,192 KB
testcase_19 AC 10 ms
14,228 KB
testcase_20 AC 4 ms
7,576 KB
testcase_21 AC 4 ms
8,028 KB
testcase_22 AC 2 ms
5,664 KB
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define MAX 999999
#define mod 1000000009


long long dp[201][2000][2];
long long dp2[201][2000][2];

long long dpans[2000];
long long dp2ans[2000];


int main() {
	string M, D;
	cin >> M >> D;

	long now = 0;
	dp[0][0][0] = 1;
	for (int i = 0; i < M.size(); i++)
	{
		int num = M[(int)M.size() - 1 - i] - '0';
		for (int j = 0; j < 2000; j++)
		{
			for (int l = 0; l < 2; l++)
			{
				if (dp[i][j][l] == 0) continue;
				dp[i][j][l] %= mod;
				for (int k = 0; k < 10; k++)
				{
					if (k < num) dp[i + 1][(j + k)][0] += dp[i][j][l];
					else if (k>num)dp[i + 1][(j + k)][1] += dp[i][j][l];
					else dp[i + 1][(j + k)][l] += dp[i][j][l];
				}
			}
		}
	}

	dp2[0][0][0] = 1;
	for (int i = 0; i < D.size(); i++)
	{
		int num = D[(int)D.size() - 1 - i] - '0';
		for (int j = 0; j < 2000; j++)
		{
			for (int l = 0; l < 2; l++)
			{
				if (dp2[i][j][l] == 0) continue;
				dp2[i][j][l] %= mod;

				for (int k = 0; k < 10; k++)
				{
					if (k < num) dp2[i + 1][(j + k)][0] += dp2[i][j][l];
					else if (k > num)dp2[i + 1][(j + k)][1] += dp2[i][j][l];
					else dp2[i + 1][(j + k)][l] += dp2[i][j][l];
				}
			}
		}
	}

	for (int i = 0; i < 2000; i++)
	{
		dpans[i] = dp[M.size()][i][0] % mod;
		dp2ans[i] = dp2[D.size()][i][0] % mod;
	}

	long long ans = 0;
	for (int i = 0; i < 2000; i++)
	{
		ans += dpans[i] * dp2ans[i];
		ans %= mod;
	}
	ans += (mod - 1);
	ans %= mod;
	cout << ans << endl;
}
0