結果

問題 No.189 SUPER HAPPY DAY
ユーザー sugim48sugim48
提出日時 2015-04-22 01:00:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 66 ms / 5,000 ms
コード長 1,431 bytes
コンパイル時間 1,399 ms
コンパイル使用メモリ 96,684 KB
実行使用メモリ 5,052 KB
最終ジャッジ日時 2023-09-18 07:11:41
合計ジャッジ時間 3,316 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
4,856 KB
testcase_01 AC 43 ms
4,844 KB
testcase_02 AC 44 ms
4,916 KB
testcase_03 AC 45 ms
4,944 KB
testcase_04 AC 44 ms
4,912 KB
testcase_05 AC 45 ms
5,052 KB
testcase_06 AC 45 ms
4,864 KB
testcase_07 AC 45 ms
4,916 KB
testcase_08 AC 45 ms
4,856 KB
testcase_09 AC 45 ms
4,916 KB
testcase_10 AC 45 ms
4,920 KB
testcase_11 AC 45 ms
4,940 KB
testcase_12 AC 44 ms
4,880 KB
testcase_13 AC 58 ms
4,908 KB
testcase_14 AC 64 ms
4,844 KB
testcase_15 AC 59 ms
4,940 KB
testcase_16 AC 59 ms
4,884 KB
testcase_17 AC 62 ms
4,940 KB
testcase_18 AC 58 ms
4,928 KB
testcase_19 AC 66 ms
4,908 KB
testcase_20 AC 53 ms
4,936 KB
testcase_21 AC 56 ms
4,876 KB
testcase_22 AC 47 ms
4,920 KB
testcase_23 AC 44 ms
4,908 KB
testcase_24 AC 44 ms
4,904 KB
testcase_25 AC 44 ms
4,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0