Cod sursa(job #735737)

Utilizator robertpoeRobert Poenaru robertpoe Data 17 aprilie 2012 10:32:42
Problema Dirichlet Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <cstdio>
#define mod 9999991
#include<fstream>
using namespace std;
ifstream f("dirichlet.in");
ofstream g("dirichlet.out");
int n,rez;
int solve(int nr, int exp)
{
    if(exp==0)
        return 1;
    int aux=solve(nr, exp/2);
    if(exp%2)
        return ((1LL*aux*aux)%mod*nr)%mod;
    return (1LL*aux*aux)%mod;
}
int main()
{
    f>>n;
    rez=1;
    for(int i=2; i<=n; ++i)
        rez=(1LL*rez*i)%mod;
    rez=solve(rez, mod-2);
    for(int i=n+2; i<=2*n; ++i)
        rez=(1LL*rez*i)%mod;
    g<<rez;
    return 0;
}