結果

問題 No.189 SUPER HAPPY DAY
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-05-13 13:05:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 1,234 bytes
コンパイル時間 1,909 ms
コンパイル使用メモリ 148,552 KB
実行使用メモリ 11,344 KB
最終ジャッジ日時 2023-09-20 05:12:01
合計ジャッジ時間 3,876 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
11,152 KB
testcase_01 AC 6 ms
11,180 KB
testcase_02 AC 6 ms
11,124 KB
testcase_03 AC 7 ms
11,128 KB
testcase_04 AC 6 ms
11,188 KB
testcase_05 AC 6 ms
11,212 KB
testcase_06 AC 6 ms
11,288 KB
testcase_07 AC 6 ms
11,164 KB
testcase_08 AC 6 ms
11,112 KB
testcase_09 AC 6 ms
11,268 KB
testcase_10 AC 6 ms
11,324 KB
testcase_11 AC 6 ms
11,124 KB
testcase_12 AC 6 ms
11,284 KB
testcase_13 AC 8 ms
11,220 KB
testcase_14 AC 8 ms
11,288 KB
testcase_15 AC 8 ms
11,228 KB
testcase_16 AC 9 ms
11,300 KB
testcase_17 AC 9 ms
11,168 KB
testcase_18 AC 8 ms
11,192 KB
testcase_19 AC 9 ms
11,200 KB
testcase_20 AC 7 ms
11,128 KB
testcase_21 AC 7 ms
11,164 KB
testcase_22 AC 6 ms
11,160 KB
testcase_23 AC 9 ms
11,344 KB
testcase_24 AC 8 ms
11,184 KB
testcase_25 AC 11 ms
11,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
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;

i64 dp[222][2222][2];

int f(int x) { return 9*x+1; }

vector<i64> solve(string s) {
  int sz = s.size();
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for(int i : range(sz)) {
    for(int j : range(f(i))) {
      dp[i][j][0] %= mod;
      dp[i][j][1] %= mod;
      int ith = s[i] - '0';
      for(int k : range(ith)) {
        dp[i+1][j+k][1] += dp[i][j][0];
      }
      dp[i+1][j+ith][0] += dp[i][j][0];
      for(int k : range(10)) {
        dp[i+1][j+k][1] += dp[i][j][1];
      }
    }
  }
  vector<i64> res(f(sz));
  for(int i : range(f(sz))) {
    res[i] = (dp[sz][i][0] + dp[sz][i][1]) % mod;
  }
  return res;
}

int main(void) {
  string s, t; cin >> s >> t;
  vector<i64> a = solve(s);
  vector<i64> b = solve(t);
  i64 res = 0;
  for(int i : range(min(a.size(), b.size()))) {
    res += a[i] * b[i] % mod;
  }
  printf("%d\n", int((res + mod - 1) % mod));
  return 0;
}
0