結果
| 問題 | No.189 SUPER HAPPY DAY |
| コンテスト | |
| ユーザー |
kaikey
|
| 提出日時 | 2020-05-21 11:17:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 5,000 ms |
| コード長 | 3,120 bytes |
| コンパイル時間 | 1,503 ms |
| コンパイル使用メモリ | 168,808 KB |
| 実行使用メモリ | 16,172 KB |
| 最終ジャッジ日時 | 2024-10-01 23:55:01 |
| 合計ジャッジ時間 | 2,601 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1000000009;
template <std::int_fast64_t Modulus>
class modint
{
using u64 = std::int_fast64_t;
public:
u64 a;
constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
constexpr u64& value() noexcept { return a; }
constexpr const u64& value() const noexcept { return a; }
constexpr modint operator+(const modint rhs) const noexcept
{
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept
{
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept
{
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept
{
return modint(*this) /= rhs;
}
constexpr modint& operator+=(const modint rhs) noexcept
{
a += rhs.a;
if (a >= Modulus)
{
a -= Modulus;
}
return *this;
}
constexpr modint& operator-=(const modint rhs) noexcept
{
if (a < rhs.a)
{
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint& operator*=(const modint rhs) noexcept
{
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint& operator/=(modint rhs) noexcept
{
u64 exp = Modulus - 2;
while (exp)
{
if (exp % 2)
{
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
};
typedef modint<MOD> ModInt;
ModInt dpM[202][2][2000];
ModInt dpD[202][2][2000];
int main() {
cin.tie(0); ios_base::sync_with_stdio(false);
string M, Day;
cin >> M >> Day;
lint m = SZ(M), d = SZ(Day);
fill((long long*)dpM, (long long*)dpM + sizeof(dpM) / sizeof(long long), 0);
fill((long long*)dpD, (long long*)dpD + sizeof(dpD) / sizeof(long long), 0);
dpM[0][0][0] = 1;
dpD[0][0][0] = 1;
REP(i, m) {
int D = M[i] - '0';
REP(j, 2) {
REP(k, 2000) {
REP(d, (j ? 10 : D + 1)) {
dpM[i + 1][j || d < D][k + d] += dpM[i][j][k];
}
}
}
}
REP(i, d) {
int D = Day[i] - '0';
REP(j, 2) {
REP(k, 2000) {
REP(d, (j ? 10 : D + 1)) {
dpD[i + 1][j || d < D][k + d] += dpD[i][j][k];
}
}
}
}
ModInt sum = 0;
FOR(i, 1, 2000) {
sum += (dpM[m][1][i] + dpM[m][0][i]) * (dpD[d][1][i] + dpD[d][0][i]);
}
cout << sum.a << endl;
}
kaikey