Cod sursa(job #1362017)

Utilizator lorelei27LORENA GHEORGHE lorelei27 Data 26 februarie 2015 09:24:39
Problema Dirichlet Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <fstream>
using namespace std;
ifstream in("dirichlet.in");
ofstream out("dirichlet.out");
long long n,n2;
long long a = 1,b = 1,i;

long long pow(long long x, long long y)
{
    if (y == 1)
        return x;
    if (y % 2 == 0)
        return pow(x, y/2) * pow(x, y/2) % 9999991;
    else
        return (x * pow(x, y/2) % 9999991) * pow(x, y/2) % 9999991;
}

int main()
{
    in >> n;
    n2 = 2 * n;
    for (i=2; i<=n; i++)
        a = (a * i) % 9999991;
    for (i=n+2; i<=n2; i++)
        b = b * i % 9999991;
    out << (b * pow(a, 9999991 - 2) % 9999991) % 9999991 << '\n';
    return 0;
}