結果
| 問題 | No.189 SUPER HAPPY DAY | 
| コンテスト | |
| ユーザー |  ikd | 
| 提出日時 | 2018-10-05 04:41:14 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,199 bytes | 
| コンパイル時間 | 736 ms | 
| コンパイル使用メモリ | 96,604 KB | 
| 実行使用メモリ | 15,064 KB | 
| 最終ジャッジ日時 | 2024-06-13 01:45:47 | 
| 合計ジャッジ時間 | 1,990 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 13 WA * 10 | 
ソースコード
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;
  auto args = readln.split.to!(string[]);
  const long mod = 10 ^^ 9 + 9;
  long[][] solve(string n) {
    auto dp = new long[][][](n.length + 1, 2, n.length * 10);
    dp[0][0][0] = 1;
    foreach (i; 0 .. n.length) {
      foreach (l; 0 .. 2) {
        foreach (s; 0 .. (n.length * 10)) {
          auto d = l ? 9 : n[i] - '0';
          for (int digit = 0; digit <= d; digit++) {
            auto less = l || (digit < d);
            auto sum = s + digit;
            if (sum < n.length * 10) {
              (dp[i + 1][less][sum] += dp[i][l][s]) %= mod;
            }
          }
        }
      }
    }
    return dp[n.length];
  }
  auto dp1 = solve(args[0]), dp2 = solve(args[1]);
  long tot = 0;
  foreach (i; 0 .. 2) {
    foreach (j; 0 .. 2) {
      foreach (s; 1 .. (max(dp1[i].length, dp2[j].length))) {
        (tot += dp1[i][s] * dp2[j][s] % mod) %= mod;
      }
    }
  }
  writeln(tot);
}
void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;
  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}
            
            
            
        