結果

問題 No.189 SUPER HAPPY DAY
コンテスト
ユーザー yuppe19 😺
提出日時 2015-08-03 22:06:44
言語 C++11(old_compat)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -include bits/stdc++.h -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 46 ms / 5,000 ms
コード長 1,163 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,728 ms
コンパイル使用メモリ 175,684 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2026-03-08 16:03:10
合計ジャッジ時間 2,997 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
using namespace std;
using i64 = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

const int mod = 1000000009;

vector<i64> f(string s) {
  int n = s.size();
  vector<vector<vector<i64>>> dp(n+1, vector<vector<i64>>(2, vector<i64>(2222)));
  dp[0][0][0] = 1;
  for(int i : range(n)) {
    for(int j : range(2)) {
      for(int x : range(2200)) {
        for(int d : range(j?10:s[i]-'0'+1)) {
          int flag = j | d < s[i] - '0';
          dp[i+1][flag][x+d] += dp[i][j][x];
          dp[i+1][flag][x+d] %= mod;
        }
      }
    }
  }
  vector<i64> res(2200);
  for(int i : range(2200)) {
    res[i] = (dp[n][0][i] + dp[n][1][i]) % mod;
  }
  --res[0];
  return res;
}

int main(void) {
  string m, d; cin >> m >> d;
  vector<i64> r0 = f(m),
              r1 = f(d);
  i64 res = 0;
  for(int i : range(2200)) {
    res += r0[i] * r1[i] % mod;
    res %= mod;
  }
  printf("%d\n", int(res));
  return 0;
}
0