Pagini recente » Cod sursa (job #2503923) | Cod sursa (job #3163480) | Cod sursa (job #255326) | Cod sursa (job #3231680) | Cod sursa (job #1028039)
#include<fstream>
using namespace std;
long long int fact(long long int i)
{
if( i<=1)
return 1;
else return i*fact(i-1);
}
int main()
{
long long int r,nr,contor;
int d;
nr=0;
ifstream in("pascal.in");
ofstream out("pascal.out");
in>>r>>d;
if(r % 2 == 1)
{
for(contor = 0;contor<=r/2;contor++)
if(((fact(r))/(fact(r-contor)*fact(contor)))%d==0 ) nr+=2;
}
else
{
for(contor = 0;contor<=r/2-1;contor++)
if(((fact(r))/(fact(r-contor)*fact(contor)))%d==0 ) nr+=2;
if(((fact(r))/(fact(r-(r/2))*fact(r/2)))%d==0 ) nr++;
}
out<<nr;
out.close();
in.close();
return 0;
}