結果

問題 No.189 SUPER HAPPY DAY
ユーザー satakesatake
提出日時 2022-09-13 14:29:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 201,244 KB
実行使用メモリ 9,940 KB
最終ジャッジ日時 2023-08-20 16:27:18
合計ジャッジ時間 3,014 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
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 11 ms
9,784 KB
testcase_24 AC 11 ms
9,728 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 710
#endif

const int MOD = 1e9+9;

vector<ll> solve(string s){
	int n = s.size();
	ll dp[n+1][2000][2];
	for(int i = 0; i < n+1; i++){
		for(int j = 0; j < 2000; j++){
			for(int k = 0; k < 2; k++){
				dp[i][j][k] = 0;
			}
		}
	}
	dp[0][0][0] = 1;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < 2000; j++){
			for(int k = 0; k < 2; k++){
				for(int d = 0; d <= (k ? 9: (s[i]-'0')); d++){
					dp[i+1][j+d][k | (d < (s[i]-'0'))] += dp[i][j][k];
				}
			}
		}
	}

	vector<long long> ret(2000, 0);
	for(int i = 0; i < 2000; i++){
		ret[i] = dp[n][i][0] + dp[n][i][1];
		ret[i] %= MOD;
	}
	
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string m, d;
	cin >> m >> d;
	auto v = solve(m);
	auto w = solve(d);
	debug(v);
	debug(w);
	ll ans = 0;
	for(int i = 1; i < 2000; i++){
		ans += v[i] * w[i];
		ans %= MOD;
	}
	cout << ans << endl;
}
0