結果
問題 | No.129 お年玉(2) |
ユーザー |
|
提出日時 | 2016-08-30 23:06:47 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 333 ms / 5,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 903 ms |
コンパイル使用メモリ | 111,136 KB |
実行使用メモリ | 413,312 KB |
最終ジャッジ日時 | 2024-06-12 03:54:39 |
合計ジャッジ時間 | 8,269 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
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];}