結果

問題 No.189 SUPER HAPPY DAY
ユーザー tsutajtsutaj
提出日時 2017-07-14 15:55:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 792 bytes
コンパイル時間 1,636 ms
コンパイル使用メモリ 168,648 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-04-16 19:48:11
合計ジャッジ時間 2,841 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,112 KB
testcase_01 AC 5 ms
10,132 KB
testcase_02 AC 5 ms
10,112 KB
testcase_03 AC 5 ms
10,112 KB
testcase_04 AC 5 ms
10,240 KB
testcase_05 AC 4 ms
10,240 KB
testcase_06 AC 5 ms
10,184 KB
testcase_07 AC 6 ms
10,112 KB
testcase_08 AC 6 ms
10,208 KB
testcase_09 AC 4 ms
10,240 KB
testcase_10 AC 4 ms
10,068 KB
testcase_11 AC 5 ms
10,156 KB
testcase_12 AC 6 ms
10,172 KB
testcase_13 AC 10 ms
10,240 KB
testcase_14 AC 10 ms
10,088 KB
testcase_15 AC 12 ms
10,112 KB
testcase_16 AC 13 ms
10,112 KB
testcase_17 AC 13 ms
10,112 KB
testcase_18 AC 11 ms
10,240 KB
testcase_19 AC 14 ms
10,052 KB
testcase_20 AC 6 ms
10,240 KB
testcase_21 AC 7 ms
10,128 KB
testcase_22 AC 5 ms
10,240 KB
testcase_23 AC 13 ms
10,112 KB
testcase_24 AC 13 ms
10,112 KB
testcase_25 AC 21 ms
10,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;
typedef long long int ll;
constexpr ll MOD = 1000000009;

// digit, sum, flag
ll dp[210][2000][2];

vector<ll> solve(string s) {
	int N = s.length();
	memset(dp, 0, sizeof(dp));
	dp[0][0][0] = 1;

	rep(i,0,N) rep(j,0,2000) rep(f,0,2) {
		if(dp[i][j][f] == 0) continue;
		int lim = f ? 9 : s[i] - '0';
		rep(x,0,lim+1) {
			(dp[i+1][j+x][f || x < lim] += dp[i][j][f]) %= MOD;
		}
	}
	vector<ll> ret;
	rep(i,0,2000) {
		ll val = (dp[N][i][0] + dp[N][i][1]) % MOD;
		ret.push_back(val);
	}
	return ret;
}

int main() {
	string M, D; cin >> M >> D;
	vector<ll> vl = solve(M), vr = solve(D);
	int S = vl.size();
	ll ans = 0;
	rep(i,1,S) {
		(ans += vl[i] * vr[i]) %= MOD;
	}
	cout << ans << endl;
	return 0;
}
0