結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー nebukuro09nebukuro09
提出日時 2016-11-16 10:06:19
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 663 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 96,280 KB
実行使用メモリ 6,156 KB
最終ジャッジ日時 2023-09-02 22:54:40
合計ジャッジ時間 1,144 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,156 KB
testcase_01 AC 12 ms
6,088 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;

void main() {
  const int MOD = 10^^9+9;
  int M = (10L^^10/111111L).to!int;
  auto dp = new int[][](10, M+1);
  foreach (i; 0..10)
    foreach (j; 0..M+1) {
      if (i == 0 || j == 0)
        dp[i][j] = 1;
      else if (j-i >= 0)
        dp[i][j] = (dp[i-1][j] + dp[i][j-i]) % MOD;
      else
        dp[i][j] = dp[i-1][j];
    }

  int T = readln.chomp.to!int;
  foreach (t; 0..T) {
    writeln(dp[9][(readln.chomp.to!long/111111L).to!int]);
  }
}
0