Cod sursa(job #636032)

Utilizator SpiderManSimoiu Robert SpiderMan Data 19 noiembrie 2011 16:29:17
Problema Dirichlet Scor 100
Compilator cpp Status done
Runda .com 2011 Marime 0.7 kb
# include <cstdio>

const char *FIN = "dirichlet.in", *FOU = "dirichlet.out";
const int MAX = 1000005, MOD = 9999991;

int N, C[MAX];

inline int put (int N, int P) {
    int sol = 1;
    for (; P; P >>= 1) {
        if (P & 1)
            sol = (1LL * sol * N) % MOD;
        N = (1LL * N * N) % MOD;
    }
    return sol;
}

inline int cat (int N) {
    int aux = 1, sol = 1;
    for (int i = 2; i <= N; ++i)
        aux = (1LL * aux * i) % MOD;
    for (int i = N + 2; i <= N << 1; ++i)
        sol = (1LL * sol * i) % MOD;
    return ((1LL * sol * put (aux, MOD - 2)) % MOD);
}

int main (void) {
    fscanf (fopen (FIN, "r"), "%d", &N);
    fprintf (fopen (FOU, "w"), "%d", cat (N));
}