Cod sursa(job #984523)

Utilizator mitrutstrutMitrea Andrei Ionut mitrutstrut Data 14 august 2013 18:07:36
Problema Dirichlet Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <fstream>
#define MOD 9999991
#define In "dirichlet.in"
#define Out "dirichlet.out"
 
using namespace std;
long long n,rez;
inline void Read()
{
    ifstream f(In);
    f>>n;
    f.close();
}
 
inline int PowLog(int n,int k)
{
    long long p = 1;
    while(k)
    {
        if(k&1)
        {
            p = (1LL*p*n)%MOD;
            --k;
        }
        k>>=1;
        n = (1LL*n*n)%MOD;
    }
    return p;
}
ofstream g(Out);
inline void Solve()
{
    long long i,f,rez;
    for(i = 2,f = 1;i <= n;++i)
        f = (1LL*f*i)%MOD;
    f = PowLog(f,MOD-2);
    for(i = n+2,rez = 1;i <= 2*n; ++i)
        rez = (1LL*rez*i)%MOD;
    g<<1LL*rez*f%MOD<<"\n";
    g.close();
}
 
int main()
{
    Read();
    Solve();
    return 0;
}