Cod sursa(job #1244219)

Utilizator alex.vasiuVasiu Alexandru alex.vasiu Data 16 octombrie 2014 21:50:10
Problema Pascal Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <fstream>

using namespace std;
ifstream f("pascal.in");
ofstream g("pascal.out");
long long int fact(int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return n*fact(n-1);
}
long long int solve(int a,int b)
{
    return fact(a)/(fact(a-b)*fact(b));
}
int main()
{
    int r,d;
    f>>r>>d;
    f.close();
    int ok=0;
    for(int j=1;j<r;j++)
        if(solve(r,j)%d==0)
        ok++;
            g<<ok;
      g.close();
}