Cod sursa(job #777067)
#include <fstream>
using namespace std;
ifstream f("pascal.in");
ofstream g("pascal.out");
int d,r,i,P[7],ANS=0,m;
int main ()
{
f >> r >> d;
for (i=1;i<=r;i++)
{
m=r-i+1;
while (m%2==0) P[2]++,m/=2;
while (m%3==0) P[3]++,m/=3;
while (m%5==0) P[5]++,m/=5;
m=i;
while (m%2==0) P[2]--,m/=2;
while (m%3==0) P[3]--,m/=3;
while (m%5==0) P[5]--,m/=5;
P[6]=min(P[2],P[3]);
if (d==2 && P[2]>0) ANS++;
if (d==3 && P[3]>0) ANS++;
if (d==4 && P[2]>1) ANS++;
if (d==5 && P[5]>0) ANS++;
if (d==6 && P[6]>0) ANS++;
}
g << ANS << '\n';
f.close();g.close();
return 0;
}