33452023-02-26 19:55:57zsomborJáték (50 pont)cpp17Accepted 50/508ms6760 KiB
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

ll MOD = 1e9 + 7, mi;
vector <ll> fak(2e5 + 1, 1);

ll ext_eu(ll a, ll b, ll& x, ll& y) {
    if (!b) { x = 1; y = 0; return a; }
    ll X, Y, g;
    g = ext_eu(b, a % b, Y, X);
    x = X;
    y = Y - (a / b) * X;
    return g;
}

ll mod_inv(ll a) {
    ll x, y;
    ext_eu(a, MOD, x, y);
    x += MOD * MOD;
    x %= MOD;
    return x;
}

ll alatt(ll n, ll k) {
    int ret = fak[n];
    ret = (mod_inv(fak[k]) * ret) % MOD;
    ret = (mod_inv(fak[n - k]) * ret) % MOD;
    return ret;
}

int main()
{
    for (int i = 1; i <= 2e5; i++) fak[i] = (i * fak[i - 1]) % MOD;
    ll B, C;
    cin >> B >> C;
    cout << (alatt(2 * C - B - 1, C - B) - alatt(2 * C - B - 1, C - B - 1) + MOD) % MOD;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/08ms4724 KiB
2Accepted0/08ms4928 KiB
3Accepted2/28ms5272 KiB
4Accepted3/38ms5580 KiB
5Accepted3/38ms5800 KiB
6Accepted3/38ms6008 KiB
7Accepted3/38ms6224 KiB
8Accepted3/38ms6176 KiB
9Accepted3/38ms6140 KiB
10Accepted3/38ms6392 KiB
11Accepted3/38ms6272 KiB
12Accepted3/38ms6276 KiB
13Accepted3/38ms6604 KiB
14Accepted3/38ms6488 KiB
15Accepted3/38ms6556 KiB
16Accepted3/38ms6760 KiB
17Accepted3/38ms6636 KiB
18Accepted3/38ms6636 KiB
19Accepted3/38ms6636 KiB