46032023-03-30 11:13:22Error42Játék (50 pont)cpp17Wrong answer 5/504ms4164 KiB
#include <iostream>

using namespace std;

using ll = long long;

template <ll M>
struct modular {
    ll val;

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

    [[nodiscard]] modular operator +(const modular& rhs) const {
        return val + rhs.val;
    }

    [[nodiscard]] modular operator -(const modular& rhs) const {
        return val + M - rhs.val;
    }

    [[nodiscard]] modular operator *(const modular& rhs) const {
        return val * rhs.val;
    }

    // p >= 0
    [[nodiscard]] modular pow(const ll& p) const {
        if (p == 0)
            return 1;

        if (p % 2 == 0)
            return (*this * *this).pow(p / 2);
        else
            return *this * pow(p - 1);
    }

    [[nodiscard]] modular inv() const {
        return pow(M - 2);
    }

    [[nodiscard]] modular operator /(const modular& rhs) const {
        return *this * rhs.inv();
    }

    modular& operator +=(const modular& rhs) {
        return *this = *this + rhs;
    }

    modular& operator -=(const modular& rhs) {
        return *this = *this - rhs;
    }

    modular& operator *=(const modular& rhs) {
        return *this = *this * rhs;
    }

    modular& operator /=(const modular& rhs) {
        return *this = *this / rhs;
    }

    explicit operator ll() const {
        return val;
    }
};

template <ll M>
ostream& operator<<(ostream& os, const modular<M>& modular) {
    cout << modular.val;
    return os;
}

using mod = modular<1'000'000'007>;

mod nck(ll const& n, ll const& k) {
    ll ans = 1;

    for (ll i = n - k + 1; i <= n; i++)
        ans *= i;

    for (ll i = 2; i <= k; i++)
        ans /= i;

    return ans;
}

int main() {
    ll b, c;
    cin >> b >> c;

    cout << nck(2 * c - b - 1, c - b) - nck(2 * c - b - 1, c - b - 1) << "\n";
}
SubtaskSumTestVerdictTimeMemory
base5/50
1Accepted0/03ms1876 KiB
2Wrong answer0/03ms2212 KiB
3Accepted2/23ms2292 KiB
4Accepted3/33ms2428 KiB
5Wrong answer0/33ms2640 KiB
6Wrong answer0/33ms2848 KiB
7Wrong answer0/33ms3060 KiB
8Wrong answer0/33ms3184 KiB
9Wrong answer0/33ms3300 KiB
10Wrong answer0/33ms3220 KiB
11Wrong answer0/33ms3248 KiB
12Wrong answer0/33ms3448 KiB
13Wrong answer0/33ms3660 KiB
14Wrong answer0/34ms3872 KiB
15Wrong answer0/33ms3880 KiB
16Wrong answer0/34ms4028 KiB
17Wrong answer0/34ms4164 KiB
18Wrong answer0/33ms4092 KiB
19Wrong answer0/34ms4096 KiB