結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー te-shte-sh
提出日時 2016-09-03 15:08:13
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 768 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 104,952 KB
実行使用メモリ 6,200 KB
最終ジャッジ日時 2023-09-02 21:53:11
合計ジャッジ時間 1,475 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,368 KB
testcase_01 AC 13 ms
6,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const auto mod = 10 ^^ 9 + 9;

void main()
{
  auto t = readln.chomp.to!int;
  auto mi = iota(t).map!(_ => readln.chomp.to!long);
  auto ni = mi.map!(m => (m / 111111).to!int).array;

  auto maxN = ni.reduce!(max);
  auto memo = new int[](maxN + 1);
  memo[] = 1;

  foreach (i; 1..10) {
    auto memo2 = new int[](maxN + 1);
    foreach (j; 0..maxN + 1) {
      memo2[j] = (memo[j] + (j >= i ? memo2[j - i] : 0)) % mod;
    }
    foreach (j; 0..maxN + 1) {
      memo[j] = (memo[j] + (j >= i ? memo2[j - i] : 0)) % mod;
    }
  }

  foreach (n; ni)
    writeln(memo[n]);
}
0