結果

問題 No.189 SUPER HAPPY DAY
ユーザー btkbtk
提出日時 2015-04-22 01:32:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 1,307 bytes
コンパイル時間 1,316 ms
コンパイル使用メモリ 84,844 KB
実行使用メモリ 9,664 KB
最終ジャッジ日時 2023-09-18 07:36:25
合計ジャッジ時間 2,809 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,712 KB
testcase_01 AC 12 ms
6,592 KB
testcase_02 AC 12 ms
6,472 KB
testcase_03 AC 13 ms
6,552 KB
testcase_04 AC 12 ms
6,572 KB
testcase_05 AC 12 ms
6,744 KB
testcase_06 AC 12 ms
6,604 KB
testcase_07 AC 12 ms
6,576 KB
testcase_08 AC 12 ms
6,544 KB
testcase_09 AC 12 ms
6,672 KB
testcase_10 AC 12 ms
6,556 KB
testcase_11 AC 12 ms
6,552 KB
testcase_12 AC 13 ms
6,672 KB
testcase_13 AC 18 ms
8,424 KB
testcase_14 AC 20 ms
8,492 KB
testcase_15 AC 19 ms
9,212 KB
testcase_16 AC 20 ms
9,520 KB
testcase_17 AC 21 ms
9,664 KB
testcase_18 AC 19 ms
9,164 KB
testcase_19 AC 22 ms
9,084 KB
testcase_20 AC 16 ms
8,212 KB
testcase_21 AC 17 ms
7,836 KB
testcase_22 AC 13 ms
6,792 KB
testcase_23 AC 16 ms
9,628 KB
testcase_24 AC 16 ms
9,596 KB
testcase_25 AC 16 ms
9,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;
#define LL long long
const LL MOD = (LL)1e9 + 9;
LL nine[300][2000];
string M, D;
void dfs(int n,LL res[],string &s){
	s[n] -= '0';
	for (int i = 0; i < 1991; i++)
		for (int j = 0; j <(int)s[n] ; j++)
			res[i + j] = (res[i + j] + nine[s.size() - n - 1][i]) % MOD;
	
	LL left[2000] = { 0 };
	if (n+1 < (int)s.size()){
		dfs(n + 1, left, s);
		for (int i = 0; i < 1991; i++)
			res[i + s[n]] = (res[i + s[n]] + left[i]) % MOD;
	}
	else res[s[n]] = (res[s[n]]+1)%MOD;

	
}

int main(void){

	for (int i = 0; i < 10; i++)
		nine[1][i] = 1;
	for (int i = 2; i <= 200; i++)
		for (int j = 0; j < 1991; j++)
			for (int k = 0; k < 10; k++)
				nine[i][j + k] = (nine[i][j + k]+ nine[i - 1][j])%MOD;
	nine[0][0] = 1;
	cin >> M >> D;
	LL res1[2000] = { 0 };
	LL res2[2000] = { 0 };
	LL ans = 0;
	dfs(0, res1, M);
	dfs(0, res2, D);
	for (int i = 1; i < 2000; i++)
		ans = (ans + res1[i] * res2[i]) % MOD;
//	reverse(M.begin(), M.end());
//	reverse(D.begin(), M.end());
	cout << ans << endl;
	return(0);
}
0