Pagini recente » Cod sursa (job #988719) | Cod sursa (job #900059) | Cod sursa (job #2654409) | Cod sursa (job #763355) | Cod sursa (job #635707)
Cod sursa(job #635707)
#include <stdio.h>
typedef long long ll;
const char IN[]="dirichlet.in",OUT[]="dirichlet.out";
const int mod = 9999991;
int N,doiN;
int PN,PdoiN;
void gcd(ll &x,ll &y,int a,int b){
if (!b)
x = 1 , y = 0;
else
{
gcd(x,y,b,a%b);
ll aux=x;
x=y;
y= aux- y*(a/b);
}
}
int inv(int x){
ll inv,ins;
gcd(inv,ins,x,mod);
if (inv<=0)
inv= mod + inv%mod;
return inv;
}
void perm()
{
int i,p=1;
for (i=1;i<=doiN;++i)
{
p=1LL*i*p%mod;
if (i==N) PN=p;
}
PdoiN=p;
}
int main()
{
freopen(IN,"r",stdin);
scanf("%d",&N);doiN=2*N;
fclose(stdin);
perm();
//printf("%d %d\n",PdoiN,PN);
int rez= (1LL*PdoiN*inv(PN))%mod*(ll)inv(PN)%mod*(ll)inv(N+1)%mod;
freopen(OUT,"w",stdout);
printf("%d\n",rez);
fclose(stdout);
return 0;
}