37032023-03-02 11:59:44gortomiJáték (50 pont)cpp17Accepted 50/5014ms13004 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9 + 7;
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int b, c;
    cin >> b >> c;
    const int e = 2e5 + 1;
    vector<int> inv_num(e);
    inv_num[1] = 1;
    for(int i = 2; i < e; i++)
    {
        inv_num[i] = (((MOD + i - 1) / i) * inv_num[i - (MOD % i)]) % MOD;
    }
    vector<int> inv(e);
    inv[0] = 1;
    for(int i = 1; i < e; i++) inv[i] = (inv[i - 1] * inv_num[i]) % MOD;
    vector<int> fac(e);
    fac[0] = 1;
    for(int i = 1; i < e; i++) fac[i] = (fac[i - 1] * i) % MOD;
    int all = fac[2 * c - b - 1];
    all *= inv[c - 1];
    all %= MOD;
    all *= inv[c - b];
    all %= MOD;
    int bad = fac[2 * c - b - 1];
    bad *= inv[c];
    bad %= MOD;
    bad *= inv[c - b - 1];
    bad %= MOD;
    int ans = all - bad;
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    cout << ans;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/014ms11092 KiB
2Accepted0/014ms11352 KiB
3Accepted2/214ms11308 KiB
4Accepted3/314ms11512 KiB
5Accepted3/314ms11732 KiB
6Accepted3/314ms11960 KiB
7Accepted3/314ms12088 KiB
8Accepted3/314ms12332 KiB
9Accepted3/314ms12544 KiB
10Accepted3/314ms12504 KiB
11Accepted3/314ms12500 KiB
12Accepted3/314ms12628 KiB
13Accepted3/314ms12500 KiB
14Accepted3/314ms12756 KiB
15Accepted3/314ms12712 KiB
16Accepted3/314ms12712 KiB
17Accepted3/314ms12992 KiB
18Accepted3/314ms13004 KiB
19Accepted3/314ms12796 KiB