結果

問題 No.189 SUPER HAPPY DAY
ユーザー FF256grhyFF256grhy
提出日時 2018-01-14 16:24:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 5,000 ms
コード長 2,218 bytes
コンパイル時間 1,904 ms
コンパイル使用メモリ 166,368 KB
実行使用メモリ 14,704 KB
最終ジャッジ日時 2023-08-25 17:23:41
合計ジャッジ時間 3,651 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,464 KB
testcase_01 AC 5 ms
5,616 KB
testcase_02 AC 2 ms
5,668 KB
testcase_03 AC 6 ms
5,864 KB
testcase_04 AC 5 ms
5,664 KB
testcase_05 AC 5 ms
5,592 KB
testcase_06 AC 6 ms
5,592 KB
testcase_07 AC 6 ms
5,584 KB
testcase_08 AC 6 ms
5,668 KB
testcase_09 AC 6 ms
5,588 KB
testcase_10 AC 5 ms
5,660 KB
testcase_11 AC 6 ms
5,808 KB
testcase_12 AC 5 ms
5,664 KB
testcase_13 AC 59 ms
10,372 KB
testcase_14 AC 77 ms
12,048 KB
testcase_15 AC 64 ms
10,784 KB
testcase_16 AC 67 ms
10,988 KB
testcase_17 AC 78 ms
10,300 KB
testcase_18 AC 62 ms
10,596 KB
testcase_19 AC 92 ms
11,696 KB
testcase_20 AC 35 ms
8,476 KB
testcase_21 AC 42 ms
8,752 KB
testcase_22 AC 12 ms
5,980 KB
testcase_23 AC 46 ms
10,968 KB
testcase_24 AC 48 ms
9,092 KB
testcase_25 AC 94 ms
14,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 1800;
string s[2];
LL b[2][M + 1], dp[2][202][2][M + 1], MOD = 1e9 + 9;

void count(int p) {
	int n = s[p].size();
	dp[p][0][1][0] = 1;
	inc(i, n) {
	incII(sum, 0, M - 9) {
		int D = s[p][i] - '0';
		inc(d, 10) { (dp[p][i + 1][0][sum + d] += dp[p][i][0][sum]) %= MOD; }
		inc(d,  D) { (dp[p][i + 1][0][sum + d] += dp[p][i][1][sum]) %= MOD; }
		             (dp[p][i + 1][1][sum + D] += dp[p][i][1][sum]) %= MOD;
	}
	}
	
	incII(sum, 0, M) { b[p][sum] = (dp[p][n][0][sum] + dp[p][n][1][sum]) % MOD; }
}

int main() {
	inc(i, 2) { cin >> s[i]; }
	
	inc(i, 2) { count(i); }
	LL ans = 0;
	inc1(i, M) { (ans += b[0][i] * b[1][i] % MOD) %= MOD; }
	
	cout << ans << endl;
	
	return 0;
}
0