結果

問題 No.189 SUPER HAPPY DAY
ユーザー btk
提出日時 2015-04-22 01:18:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,279 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 84,988 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-07-04 23:28:46
合計ジャッジ時間 6,146 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2 RE * 1
other WA * 1 RE * 22
権限があれば一括ダウンロードができます

ソースコード

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