Cod sursa(job #2535822)
Utilizator | Gheorghita Vlad Gheorghita_Vlad | Data | 1 februarie 2020 11:42:00 |
---|---|---|---|
Problema | Dirichlet | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <fstream>
#define M 9999991
using namespace std;
ifstream f("dirichlet.in");
ofstream g("dirichlet.out");
int n;
long long putere(int x, int n)
{
if (n==0) return 1;
if (n==1) return x%M;
long long y=putere(x,n/2);
y=(y*y)%M;
if (n%2==1) y=y*x%M;
return y;
}
long long comb(int n, int k)
{
long long i,s=1,t=1;
for (i=1;i<=n;i++)
{
s=(s*i)%M;
if (i<=k) t=(t*i)%M;
if (i<=n-k) t=(t*i)%M;
}
t=putere(t,M-2)%M;
return (s*t)%M;
}
int main()
{
f>>n;
g<<comb(2*n,n)*putere(n+1,M-2)%M;
return 0;
}