Cod sursa(job #2330576)

Utilizator ionanghelinaIonut Anghelina ionanghelina Data 28 ianuarie 2019 16:58:52
Problema Dirichlet Scor 88
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.76 kb
#include<bits/stdc++.h>
using namespace std;

const int mod=9999991;



inline int fastexp(long long a,long long b)
{
    long long res=1LL;
    while(b)
    {
        if(b&1)
        {
            res=(res*a)%mod;
            b--;
        }
            else
        {
            a=(a*a)%mod;
            b>>=1;
        }
    }

    return res;
}

inline long long invmod(int x)
{
    return fastexp(x,mod-2);
}

int n;

int main()
{
    freopen("dirichlet.in","r",stdin);
    freopen("dirichlet.out","w",stdout);

    scanf("%d",&n);

    long long sol=1LL;

    for(int i=n+2;i<=2*n;i++)
        sol=(sol*i)%mod;

    for(int i=1;i<=n;i++)
        sol=(sol*invmod(i))%mod;





    printf("%lld\n",sol);
    return 0;
}