Pagini recente » Cod sursa (job #3321690) | Cod sursa (job #3326150)
#include <fstream>
#include <string>
using namespace std;
const int MOD = 1e7 - 9;
const string fileName = "dirichlet";
#define fileIn fileName + ".in"
#define fileOut fileName + ".out"
int p(int a, int b){
return 1LL * a * b % MOD;
}
int invMod(int x){
int put = MOD - 2;
int comp = x, ans = 1;
while(put){
if(put & 1) ans = p(ans, comp);
comp = p(comp, comp);
put >>= 1;
}
return ans;
}
int fact(int x){
int f = 1;
for(int i = 2; i <= x; i++)
f = p(f, i);
return f;
}
int main(){
ifstream fin(fileIn);
ofstream fout(fileOut);
int n; fin >> n;
int a = fact(2 * n), b = fact(n);
fout << p(a, invMod(p(b, p(b, n + 1))));
fin.close(); fout.close();
}