結果

問題 No.129 お年玉(2)
ユーザー shi-moshi-mo
提出日時 2016-10-28 02:13:53
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 486 bytes
コンパイル時間 1,573 ms
コンパイル使用メモリ 140,944 KB
実行使用メモリ 10,732 KB
最終ジャッジ日時 2023-09-02 22:33:19
合計ジャッジ時間 3,958 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,368 KB
testcase_05 AC 3 ms
4,368 KB
testcase_06 AC 18 ms
9,720 KB
testcase_07 AC 17 ms
9,876 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 15 ms
10,016 KB
testcase_10 AC 13 ms
9,824 KB
testcase_11 AC 16 ms
9,720 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 2 ms
4,368 KB
testcase_14 AC 17 ms
8,632 KB
testcase_15 AC 16 ms
9,712 KB
testcase_16 AC 20 ms
9,440 KB
testcase_17 AC 11 ms
9,796 KB
testcase_18 AC 13 ms
10,428 KB
testcase_19 AC 4 ms
4,372 KB
testcase_20 AC 22 ms
9,444 KB
testcase_21 AC 14 ms
9,920 KB
testcase_22 AC 13 ms
8,800 KB
testcase_23 AC 15 ms
10,732 KB
testcase_24 AC 2 ms
4,372 KB
testcase_25 AC 18 ms
9,692 KB
testcase_26 AC 6 ms
5,868 KB
testcase_27 AC 8 ms
7,408 KB
testcase_28 AC 25 ms
9,924 KB
testcase_29 AC 1 ms
4,372 KB
testcase_30 AC 1 ms
4,372 KB
testcase_31 AC 1 ms
4,372 KB
testcase_32 AC 1 ms
4,368 KB
testcase_33 AC 1 ms
4,368 KB
testcase_34 AC 2 ms
4,372 KB
testcase_35 AC 2 ms
4,368 KB
testcase_36 AC 2 ms
4,368 KB
testcase_37 AC 2 ms
4,368 KB
testcase_38 AC 4 ms
4,368 KB
testcase_39 AC 3 ms
4,368 KB
testcase_40 AC 7 ms
6,624 KB
testcase_41 AC 8 ms
6,900 KB
testcase_42 AC 4 ms
4,372 KB
testcase_43 AC 2 ms
4,368 KB
testcase_44 AC 5 ms
4,560 KB
testcase_45 AC 3 ms
4,372 KB
testcase_46 AC 2 ms
4,368 KB
testcase_47 AC 12 ms
10,328 KB
testcase_48 AC 3 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.math;
import std.bigint;

void main() {
    ulong n, m; readf("%s\n%s", &n, &m);

    ulong r = (n / 1000) % m;
    if (0 == r) {
        writeln(1);
        return;
    }
    if (m-r < r && 0 < m-r) { r = m-r; }
    writeln(c(m, r) % 10.pow(9));
}

BigInt c(ulong n, ulong k) {
    return factPart(n, k) / factPart(k, k);
}

BigInt factPart(ulong n, ulong k) {
    BigInt res = BigInt(1);
    foreach (i; 0..k) {
        res *= n-i;
    }
    return res;
}
0