結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

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 <s[n] ; j++)
			res[i + j] = (res[i + j] + nine[s.size() - n - 1][i]) % MOD;
	
	LL left[2000] = { 0 };
	if (n+1 < 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, M);
	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