Cod sursa(job #2089994)

Utilizator andrei2408Andrei Cioc andrei2408 Data 17 decembrie 2017 14:18:06
Problema Pascal Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in ("pascal.in");
ofstream out ("pascal.out");

int main()
{
    int r, d, c=0, i, j, fr, fc, fcr, nr=0;
    in>>r>>d;
    for (j=0; j<=(r+1)/2; j++)
    {
         fr=1; fc=1; fcr=1;
        for (i=1; i<=r; i++)
            fr=fr*i;
        for (i=1; i<=c; i++)
            fc=fc*i;
        for (i=1; i<=r-c; i++)
            fcr=fcr*i;

        //out<<fr/(fcr*fc)<<'\n';

        if (fr/(fcr*fc)%d==0)
          {
              nr++;
          }
        c++;
    }
   if (r%2==0)
        out<<nr*2-1;
        else out<<(nr-1)*2;

    return 0;
}