結果

問題 No.189 SUPER HAPPY DAY
ユーザー btkbtk
提出日時 2015-04-22 01:23:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,289 bytes
コンパイル時間 620 ms
コンパイル使用メモリ 84,380 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2023-09-18 07:22:10
合計ジャッジ時間 2,024 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,468 KB
testcase_01 WA -
testcase_02 AC 12 ms
6,388 KB
testcase_03 WA -
testcase_04 AC 13 ms
6,536 KB
testcase_05 WA -
testcase_06 AC 12 ms
6,628 KB
testcase_07 WA -
testcase_08 AC 12 ms
6,524 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 15 ms
9,584 KB
testcase_24 AC 16 ms
9,620 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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 + 7;
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]]++;

	
}

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