Cod sursa(job #1956140)

Utilizator cris90robert@yahoo.comseretan cristian [email protected] Data 6 aprilie 2017 15:31:51
Problema Pascal Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<iostream>
#include<fstream>
using namespace std;
long fact( long n)
{
	if(n==0)
	{
		return 1;
	}
	else
	{
		return fact(n-1)*n;
	}
}
int main()
{
	 long d,j,nr=0,r;
	
	fstream f("pascal.in",ios::in);
	f>>r>>d;
	f.close();
	for(j=0;j<=r/2-1;j++)
	{
		if(fact(r)/(fact(r-j)*fact(j))%d==0)
		{
			nr++;
		}
	}
	nr=2*nr;
	if(fact(r)/(fact(r-r/2)*(fact(r/2))%d==0)
	{
		nr++;
	}
	fstream g("pascal.out",ios::out);
	g<<nr;
	g.close();
}