Cod sursa(job #2371645)

Utilizator liviu2000Dragomirescu Liviu liviu2000 Data 6 martie 2019 18:49:30
Problema Dirichlet Scor 92
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <bits/stdc++.h>
#define N 1000005
#define MOD 9999991

using namespace std;

ifstream fin("dirichlet.in") ;
ofstream fout("dirichlet.out") ;

long long fact[2*N] ;

long long inv(long long a,long long b)
{
    return 1 < a ? b-inv(b%a,a)*b/a : 1 ;
}

int main()
{
    int n , i ;
    long long f2 ;
    fin >> n ;
    fact[1] = 1 ;
    for ( i = 2 ; i <= 2*n ; i++ )
        fact[i] = (fact[i-1]*i)%MOD ;
    f2 = (fact[n]*fact[n+1])%MOD ;
    fout << (1LL*fact[2*n]*inv(f2,MOD))%MOD ;
}