Cod sursa(job #1013232)

Utilizator mazaandreiAndrei Mazareanu mazaandrei Data 20 octombrie 2013 17:31:08
Problema Dirichlet Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include<fstream>
#define M 9999991
using namespace std;
ifstream in("dirichlet.in");
ofstream out("dirichlet.out");
int r=1,q,n,k,r2=1;;
inline long long inv(long long a, long long b){
    int p=1;
    while(b){
        if(b&1) p=(p*a)%M;
        a=(a*a)%M;
        b/=2;
    }
    return p%M;
}
int main(){
    in>>q;
    n=2*q; k=q;
    for(int i=n;i>k+1;--i)
        r=(1LL*r*i)%M;
        //r=((r%M)*(i%M))%M;
    for(int i=1;i<=k;++i)
        //r2=((r2%M)*(i%M))%M;
        r2=(1LL*r2*i)%M;
    out<<(r*inv(r2,M-2))%M<<'\n';
    return 0;
}