61652023-11-04 12:41:06horvathabelJáték (50 pont)cpp17Accepted 50/5030ms19428 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll mod=1000000007;

vector<ll> fact(1000001,0);
ll pw(ll a, ll b){
    ll ret=1;
    while (b>0){
        if (b%2==1){
            ret*=a;
            ret=ret%mod;
        }
        a*=a;
        a=a%mod;
        b/=2;
    }
    return ret;
}
ll choose(int n,int k){
    if (n==k) return 1;
    ll ret=fact[n];
    ret*=pw(fact[k],mod-2);
    ret%=mod;
    ret*=pw(fact[n-k],mod-2);
    ret=ret%mod;
    return ret;
}
int main()
{

    fact[1]=1;
    for (int i=2;i<=1000001;i++){
        fact[i]=(fact[i-1]*i);
        fact[i]%=mod;
    }
    int b,c;
    cin>>b>>c;
    ll ans=1;

    ans=choose(c-1+c-b,c-b);
    //az össz lehetoseg kozul hany helyre rakhatok b-t
    ans%=mod;
    ans-=choose(c-1+c-b,c-b-1);
    ans+=mod;
    ans%=mod;
    //hany helyre tehetem a falat, ahol "atlepi" az a szama a b szamat
    cout<<ans%mod;

}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/030ms17332 KiB
2Accepted0/029ms17528 KiB
3Accepted2/229ms18016 KiB
4Accepted3/329ms17900 KiB
5Accepted3/329ms18128 KiB
6Accepted3/330ms18208 KiB
7Accepted3/330ms18300 KiB
8Accepted3/329ms18572 KiB
9Accepted3/329ms18444 KiB
10Accepted3/329ms18632 KiB
11Accepted3/329ms18832 KiB
12Accepted3/329ms19060 KiB
13Accepted3/329ms18984 KiB
14Accepted3/329ms18984 KiB
15Accepted3/329ms18984 KiB
16Accepted3/329ms18984 KiB
17Accepted3/330ms19112 KiB
18Accepted3/330ms19196 KiB
19Accepted3/329ms19428 KiB