Cod sursa(job #58469)
Utilizator | Data | 5 mai 2007 22:10:06 | |
---|---|---|---|
Problema | Pascal | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
long double fact(long double n)
{
if ( n < 2 )
{
return 1;
}
else
{
return n * fact(n - 1);
}
}
int main ()
{
int R, D, count = 0;
ifstream in("pascal.in");
ofstream out("pascal.out");
in >> R >> D;
for ( int i = 0; i <= R; ++i )
{
if ( int ( fact(R)/(fact(R-i)*fact(i)) ) % D == 0 )
{
++count;
}
}
out << count;
return 0;
}