#include<stdio.h>
double Combination(int n,int m,int c)
{
double a=1; int i;
for(;n>c;n--,m--)
a*=(double)n/m;
return a;
}
int main()
{
int i,n,m; double a;
while(scanf("%d %d",&n,&m) == 2 && (n || m))
{
i = n-m;
if(i > m) a = Combination( n,m,i );
else a = Combination( n,i,m );
printf("%.0lf\n",a);
}
return 0;
}
/*
Input:
4 2
10 5
49 6
100 6
20 5
18 6
Output:
6
252
13983816
1192052400
15504
18564
*/
No comments:
Post a Comment