#include <stdio.h>
int binomial_coefficient(int p, int m)
{
int r = 1;
if (m > p - m)
m = p - m;
for (int i = 0; i < m; ++i) {
r *= (p - i);
r /= (i + 1);
}
return r;
}
int calculate_ways(int m, int p)
{
if (m < p)
return 0;
int ws = binomial_coefficient(p + m - 1, p - 1);
return ws;
}
int main()
{
int m = 4, p = 3;
int res = calculate_ways(m, p);
printf("%d\n", res);
return 0;
}
Comments
Leave a comment