結果

問題 No.189 SUPER HAPPY DAY
ユーザー nebukuro09nebukuro09
提出日時 2016-11-28 15:43:15
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 970 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 99,732 KB
実行使用メモリ 15,932 KB
最終ジャッジ日時 2023-09-02 23:10:14
合計ジャッジ時間 3,836 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 6 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 6 ms
4,832 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 6 ms
4,384 KB
testcase_08 AC 6 ms
4,868 KB
testcase_09 AC 6 ms
4,384 KB
testcase_10 AC 7 ms
4,384 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 6 ms
4,384 KB
testcase_13 AC 78 ms
9,304 KB
testcase_14 AC 101 ms
10,816 KB
testcase_15 AC 85 ms
9,308 KB
testcase_16 AC 87 ms
10,296 KB
testcase_17 AC 101 ms
11,608 KB
testcase_18 AC 83 ms
9,760 KB
testcase_19 AC 118 ms
12,116 KB
testcase_20 AC 45 ms
6,140 KB
testcase_21 AC 56 ms
6,980 KB
testcase_22 AC 15 ms
4,384 KB
testcase_23 AC 61 ms
9,824 KB
testcase_24 AC 61 ms
9,236 KB
testcase_25 AC 118 ms
15,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;


long mod = 10L^^9+9;

void solve(string S, ref long[][][] dp) {
  auto N = S.length;
  dp = new long[][][](N+1, 2, 1820); // keta, miman, 3wareru, 3tsuku, 8wareru
  dp[0][0][0] = 1L;
  foreach (i; 0..N)
    foreach (j; 0..2)
      foreach (k; 0..1801) {
        auto digit = j ? 9 : (S[i]-'0').to!int;
        foreach (d; 0..digit+1)
          (dp[i+1][j||(d<digit)][k+d] += dp[i][j][k]) %= mod;
      }
}

void main() {
  auto input = readln.split;
  auto A = input[0];
  auto B = input[1];
  long[][][] dp1, dp2;
  solve(A, dp1);
  solve(B, dp2);
  long ans = 0;
  foreach (k; 1..1820)
    (ans += ((dp1[A.length][0][k] + dp1[A.length][1][k]) *
             (dp2[B.length][0][k] + dp2[B.length][1][k]) % mod)) %= mod;
  writeln(ans);
}
0