Cod sursa(job #3348013)

Utilizator andreiciocanCiocan Andrei andreiciocan Data 19 martie 2026 11:00:16
Problema Sandokan Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.81 kb
#include <fstream>

using namespace std;
ifstream cin("sandokan.in");
ofstream cout("sandokan.out");
const int M=2000003;
int fact[5001];
void factorial()
{
    fact[0]=1;
    for(int i=1;i<=5000;i++)
    {
        fact[i]=(fact[i-1]*i)%M;
    }
}

int exp(int baza,int exp)
{
    int p=1;
    while(exp!=0)
    {
        if(exp%2==1)
        {
            p=(1LL*p*baza)%M;
        }
        baza=(1LL*baza*baza)%M;
        exp=exp/2;
    }
    return p;
}

long long combinari(int n,int k)
{
    long long rez=(1LL*fact[n]*exp(fact[k],M-2))%M;
    rez=(1LL*rez*exp(fact[n-k],M-2))%M;
    return rez;
}

int main()
{
    int n,k;
    cin>>n>>k;
    factorial();
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
    }
    cout<<combinari(n,k);
    return 0;
}