Pagini recente » Cod sursa (job #3233565) | Cod sursa (job #2471786) | Cod sursa (job #1100188) | Cod sursa (job #1439180) | Cod sursa (job #2232347)
#include <iostream>
#include<fstream>
using namespace std;
ifstream f("dirichlet.in");
ofstream g("dirichlet.out");
const int MOD=9999991;
void EuclidExtins(int a, int b, int &d, int &x, int &y)
{
int x1 = 0, y1 = 1;
x = 1, y = 0;
while(b != 0)
{
int q = a / b;
int r = a % b;
a = b;
b = r;
int x0 = x - x1 * q;
int y0 = y - y1 * q;
x = x1;
y = y1;
x1 = x0;
y1 = y0;
}
d = a;
}
long long inversmodular(int A, int N)
{
int X, Y, d;
EuclidExtins(A, N, d, X, Y);
X %= N;
if(X < 0)X += N;
return X;
}
int main()
{int N;
f>>N;
long long r=1;
for(int i=2;i<=N;i++)
r=(r*((N+i)*inversmodular(i,MOD))%MOD)%MOD;
g<<r;
return 0;
}