結果
問題 | No.189 SUPER HAPPY DAY |
ユーザー |
![]() |
提出日時 | 2020-12-14 13:14:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 59 ms / 5,000 ms |
コード長 | 1,135 bytes |
コンパイル時間 | 2,194 ms |
コンパイル使用メモリ | 198,856 KB |
最終ジャッジ日時 | 2025-01-17 00:30:54 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;const ll MOD = 1e9 + 9;vector<ll> cnt(string M) {vector<vector<ll>> now(2000, vector<ll>(2));now[0][0] = 1;for (auto& c : M) {vector<vector<ll>> nxt(2000, vector<ll>(2));for (int i = 0; i < 1900; i++) {for (int j = 0; j < 10; j++) {nxt[i + j][1] += now[i][1];}nxt[i + c][0] += now[i][0];for (int j = 0; j < c; j++) {nxt[i + j][1] += now[i][0];}}for (int i = 0; i < 2000; i++) {nxt[i][0] %= MOD;nxt[i][1] %= MOD;}swap(now, nxt);}vector<ll> ret(2000);for (int i = 0; i < 2000; i++) {(ret[i] = now[i][0] + now[i][1]) %= MOD;}return ret;}int main() {string M, D;cin >> M >> D;for (auto& c : M)c -= '0';for (auto& c : D)c -= '0';ll ans = -1;auto vecM = cnt(M), vecD = cnt(D);for (int i = 0; i < 2000; i++) {(ans += vecM[i] * vecD[i]) %= MOD;}cout << ans << endl;}