結果

問題 No.741 AscNumber(Easy)
ユーザー finefine
提出日時 2018-10-06 00:42:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 163,772 KB
実行使用メモリ 19,296 KB
最終ジャッジ日時 2024-04-20 17:33:52
合計ジャッジ時間 3,134 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 3 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 16 ms
18,908 KB
testcase_36 AC 9 ms
9,984 KB
testcase_37 AC 10 ms
11,136 KB
testcase_38 AC 10 ms
11,008 KB
testcase_39 AC 8 ms
9,984 KB
testcase_40 AC 11 ms
12,160 KB
testcase_41 AC 14 ms
17,152 KB
testcase_42 AC 9 ms
12,384 KB
testcase_43 AC 8 ms
8,832 KB
testcase_44 AC 12 ms
14,336 KB
testcase_45 AC 14 ms
15,104 KB
testcase_46 AC 15 ms
17,664 KB
testcase_47 AC 4 ms
6,944 KB
testcase_48 AC 18 ms
18,652 KB
testcase_49 AC 13 ms
15,360 KB
testcase_50 AC 4 ms
5,376 KB
testcase_51 AC 8 ms
9,088 KB
testcase_52 AC 17 ms
18,984 KB
testcase_53 AC 16 ms
19,296 KB
testcase_54 AC 16 ms
19,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll f[1000020], fi[1000020];

void init(int n) {
    f[0] = 1;
    for (int i = 1; i <= n + 10; i++) {
        f[i] = f[i - 1] * i % MOD;
    }
    fi[n + 10] = modpow(f[n + 10], MOD - 2);
    for (int i = n + 10; i > 0; i--) {
        fi[i - 1] = fi[i] * i % MOD;
    }
}

ll comb(int r, int c) {
    if (r < c) return 0;
    return f[r] * fi[c] % MOD * fi[r - c] % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    init(n);
    ll ans = 0;
    for (int i = 0; i <= 9; i++) {
        (ans += comb(n - 1 + i, i)) %= MOD;
    }
    cout << ans << endl;
    return 0;
}
0