結果

問題 No.129 お年玉(2)
ユーザー te-shte-sh
提出日時 2016-08-30 23:06:47
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 298 ms / 5,000 ms
コード長 658 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 97,692 KB
実行使用メモリ 413,664 KB
最終ジャッジ日時 2023-09-02 21:39:33
合計ジャッジ時間 8,657 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
26,056 KB
testcase_01 AC 298 ms
413,664 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 105 ms
175,440 KB
testcase_06 AC 158 ms
272,732 KB
testcase_07 AC 198 ms
331,828 KB
testcase_08 AC 135 ms
228,912 KB
testcase_09 AC 179 ms
306,228 KB
testcase_10 AC 209 ms
343,564 KB
testcase_11 AC 130 ms
219,576 KB
testcase_12 AC 165 ms
285,508 KB
testcase_13 AC 175 ms
298,260 KB
testcase_14 AC 167 ms
288,092 KB
testcase_15 AC 139 ms
237,936 KB
testcase_16 AC 156 ms
270,152 KB
testcase_17 AC 189 ms
325,632 KB
testcase_18 AC 180 ms
308,080 KB
testcase_19 AC 194 ms
327,244 KB
testcase_20 AC 190 ms
324,700 KB
testcase_21 AC 273 ms
404,232 KB
testcase_22 AC 136 ms
232,588 KB
testcase_23 AC 219 ms
353,848 KB
testcase_24 AC 208 ms
340,440 KB
testcase_25 AC 131 ms
220,768 KB
testcase_26 AC 133 ms
227,192 KB
testcase_27 AC 130 ms
219,528 KB
testcase_28 AC 278 ms
408,184 KB
testcase_29 AC 2 ms
4,368 KB
testcase_30 AC 2 ms
4,368 KB
testcase_31 AC 1 ms
4,372 KB
testcase_32 AC 1 ms
4,372 KB
testcase_33 AC 4 ms
5,920 KB
testcase_34 AC 3 ms
4,372 KB
testcase_35 AC 4 ms
6,148 KB
testcase_36 AC 4 ms
6,128 KB
testcase_37 AC 5 ms
6,924 KB
testcase_38 AC 31 ms
51,708 KB
testcase_39 AC 47 ms
74,792 KB
testcase_40 AC 122 ms
206,032 KB
testcase_41 AC 77 ms
127,072 KB
testcase_42 AC 36 ms
57,044 KB
testcase_43 AC 35 ms
56,832 KB
testcase_44 AC 278 ms
410,284 KB
testcase_45 AC 21 ms
32,652 KB
testcase_46 AC 53 ms
83,824 KB
testcase_47 AC 264 ms
396,492 KB
testcase_48 AC 142 ms
241,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const auto mod = 10^^9;

void main()
{
  auto n = readln.chomp.to!long / 1000;
  auto m = readln.chomp.to!long;

  auto a = n - (n / m) * m;
  writeln(combination(m, a));
}

long combination(long n, long r)
{
  auto memo = new long [][](n + 1);
  memo[0] = [1];
  foreach (i; 1..n + 1) {
    memo[i] = new long[](i + 1);
    memo[i][0] = 1;
    memo[i][i] = 1;
    foreach (j; 1..i) {
      memo[i][j] = (memo[i - 1][j - 1] + memo[i - 1][j]) % mod;
    }
  }
  return memo[n][r];
}
0