結果

問題 No.189 SUPER HAPPY DAY
ユーザー Yang33
提出日時 2017-11-02 17:17:53
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 89 ms / 5,000 ms
コード長 3,187 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 159,376 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-11-22 13:41:01
合計ジャッジ時間 3,120 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include "bits/stdc++.h"
using namespace std;
using VS = vector<string>; using LL = long long;
using VI = vector<int>; using VVI = vector<VI>;
using PII = pair<int, int>; using PLL = pair<LL, LL>;
using VL = vector<LL>; using VVL = vector<VL>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
const int INF = 1e9; const LL LINF = 1e16;
const LL MOD = 1000000009; const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 }; int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
/* ----- 2017/11/02 Problem: yukicoder189 / Link: https://yukicoder.me/problems/no/189 ----- */
/* ------------
1M1D
MD2311112132122236MMDD
XXYYXXYYXXYY"SUPER HAPPY DAY"
42210112120204=2+21+0=11+2+1=2+0+2+0SUPER HAPPY DAY
45101912341234504≠54≠51+0≠1+91+2+3+4≠1+2+3+4+5+0SUPER HAPPY DAY
kamipeipaaMMDD1SUPER HAPPY DAY
kamipeipaa1SUPER HAPPY DAYmod 1000000009
---------- */
/* ----------
-------- */
LL N;
LL ans = 0LL;
LL dp[202][1900][2][2];
LL f(string &target, int i, int sum, int less = 0, int side = 0) {
if (i == -1) {
assert(sum >= 0);
return (sum == 0);
}
LL &res = dp[i][sum][less][side];
if (res != -1)return res;
res = 0;
int num = target[i] - '0';
int Max = less ? 9 : num;
FOR(nx, 0, Max + 1) {
if (sum - nx < 0)break;
res += f(target, i - 1, sum - nx, less | (nx < Max), side)%MOD;
//debug(res);
res = (res+ MOD) % MOD;
}
return res%MOD;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
string M, D;
cin >> M >> D;
reverse(ALL(M));
reverse(ALL(D));
fill(***dp, ***dp + 202 * 1900 * 2 * 2, -1);
FOR(sum, 1, 1809 + 1) {
//debug(f(M, SZ(M) - 1, i, 0));
//debug(f(D, SZ(D) - 1, i, 0));
ans += (f(M, SZ(M) - 1, sum,0, 0) % MOD)*(f(D, SZ(D) - 1, sum, 0,1) % MOD);
//debug(ans);
ans = (ans%MOD + MOD) % MOD;
}
cout << ans << "\n";
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0