結果

問題 No.741 AscNumber(Easy)
ユーザー nanaenanae
提出日時 2018-12-31 20:32:33
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,476 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 93,264 KB
実行使用メモリ 20,252 KB
最終ジャッジ日時 2023-09-03 21:47:34
合計ジャッジ時間 3,136 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 AC 1 ms
4,388 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 21 ms
19,480 KB
testcase_36 AC 11 ms
9,792 KB
testcase_37 AC 12 ms
11,584 KB
testcase_38 AC 12 ms
12,496 KB
testcase_39 AC 10 ms
11,060 KB
testcase_40 AC 13 ms
12,308 KB
testcase_41 AC 19 ms
17,156 KB
testcase_42 AC 11 ms
11,312 KB
testcase_43 AC 9 ms
8,476 KB
testcase_44 AC 16 ms
14,180 KB
testcase_45 AC 16 ms
14,836 KB
testcase_46 AC 19 ms
17,248 KB
testcase_47 AC 4 ms
5,112 KB
testcase_48 AC 20 ms
19,704 KB
testcase_49 AC 18 ms
15,852 KB
testcase_50 AC 4 ms
4,380 KB
testcase_51 AC 9 ms
9,004 KB
testcase_52 AC 22 ms
20,252 KB
testcase_53 AC 22 ms
19,296 KB
testcase_54 AC 22 ms
19,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

enum long mod = 10 ^^ 9 + 7;

void main() {
    int n;
    scan(n);

    auto f = new long[](n + 100);
    f[0] = f[1] = 1;
    foreach (i ; 2 .. n + 100) {
        f[i] = f[i-1] * i % mod;
    }
    auto rf = new long[](n + 100);
    rf[n + 99] = powmod(f[n + 99], mod - 2, mod);
    foreach_reverse (i ; 0 .. n + 99) {
        rf[i] = rf[i+1] * (i+1) % mod;
    }

    long comb(int n, int k) {
        return f[n] * rf[k] % mod * rf[n-k] % mod;
    }

    long ans;

    foreach (i ; 0 .. 10) {
        debug {
            writeln(comb(n - 1 + i, i));
        }
        ans += comb(n - 1 + i, i);
        ans %= mod;
    }

    writeln(ans);
}

long powmod(long x, long y, long mod) {
    return y > 0 ? powmod(x, y>>1, mod)^^2 % mod * x^^(y&1) % mod : 1;
}




























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
0