結果
問題 | No.189 SUPER HAPPY DAY |
ユーザー | sugim48 |
提出日時 | 2015-04-22 01:00:17 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 66 ms / 5,000 ms |
コード長 | 1,431 bytes |
コンパイル時間 | 783 ms |
コンパイル使用メモリ | 99,300 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-04 23:22:29 |
合計ジャッジ時間 | 2,944 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#define _USE_MATH_DEFINES #include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <cfloat> #include <climits> #include <cstring> #include <cmath> #include <fstream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> i_i; typedef pair<ll, int> ll_i; typedef pair<double, int> d_i; typedef pair<ll, ll> ll_ll; typedef pair<double, double> d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000009; ll _MOD = 1000000009; double EPS = 1e-10; vector<int> f(string s, vector<vector<int> >& dp) { vector<int> a(2000); int sum = 0; for (int i = 0; i < s.length(); i++) { for (int d = 0; d < s[i] - '0'; d++) for (int x = 0; x + sum + d < 2000; x++) a[x + sum + d] = (a[x + sum + d] + dp[s.length() - i - 1][x]) % MOD; sum += s[i] - '0'; } a[sum]++; return a; } int main() { vector<vector<int> > dp(201, vector<int>(2000)); dp[0][0] = 1; for (int i = 0; i + 1 <= 200; i++) for (int d = 0; d < 10; d++) for (int x = 0; x + d < 2000; x++) dp[i + 1][x + d] = (dp[i + 1][x + d] + dp[i][x]) % MOD; string M, D; cin >> M >> D; vector<int> m = f(M, dp), d = f(D, dp); int ans = 0; for (int x = 1; x < 2000; x++) ans = (ans + (ll)m[x] * d[x]) % MOD; cout << ans << endl; }