98112024-03-07 09:34:02Error42Faültetéscpp17Accepted 100/10057ms4424 KiB
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;

ll const M = 1'000'000'007;

struct mod {
    ll val;

    // v >= 0
    mod(ll const& v) {
        if (v < M)
            val = v;
        else if (v < 2 * M)
            val = v - M;
        else
            val = v % M;
    }

    mod operator +(mod const& rhs) const {
        return val + rhs.val;
    }

    mod operator -(mod const& rhs) const {
        return val + M - rhs.val;
    }

    mod operator *(mod const& rhs) const {
        return val * rhs.val;
    }

    mod pow(ll const& p) const {
        if (p == 0)
            return 1;
        if (p % 2 == 1)
            return *this * pow(p - 1);

        mod const hp = pow(p / 2);
        return hp * hp;
    }

    mod inv() const {
        return pow(M - 2);
    }

    mod operator /(mod const& rhs) const {
        return *this * rhs.inv();
    }
};

mod fact(ll const n) {
    mod ans = 1;

    for (ll i = 2; i <= n; i++)
        ans = ans * i;

    return ans;
}

mod nck(ll const n, ll const k) {
    return fact(n) / fact(k) / fact(n - k);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;

    cout << ((nck(2 * n - 1, n - 1) - nck(2 * n - 1, n - 2)) / 2).val << "\n";
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms2020 KiB
subtask210/10
2Accepted3ms2152 KiB
3Accepted3ms2388 KiB
4Accepted3ms2756 KiB
subtask340/40
5Accepted3ms2752 KiB
6Accepted3ms2916 KiB
7Accepted3ms2980 KiB
8Accepted3ms3212 KiB
9Accepted3ms3420 KiB
10Accepted3ms3544 KiB
11Accepted3ms3640 KiB
subtask450/50
12Accepted8ms3776 KiB
13Accepted30ms3880 KiB
14Accepted48ms3980 KiB
15Accepted16ms4096 KiB
16Accepted46ms4188 KiB
17Accepted26ms4272 KiB
18Accepted23ms4276 KiB
19Accepted52ms4188 KiB
20Accepted21ms4192 KiB
21Accepted57ms4424 KiB