結果

問題 No.189 SUPER HAPPY DAY
ユーザー ikdikd
提出日時 2018-10-05 04:41:14
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,199 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 82,032 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2023-09-03 21:04:18
合計ジャッジ時間 2,500 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 50 ms
8,548 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 74 ms
12,340 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 98 ms
16,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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