MIPI_AdvancedC_FRTK/Lect5/28.c

24 lines
349 B
C
Raw Normal View History

2024-11-14 08:45:50 +03:00
#include<stdio.h>
int cnk(int n, int k) {
int res = 1;
for (int i=n-k+1; i<=n; ++i)
res *= i;
for (int i=2; i<=k; ++i)
res /= i;
return res;
}
int main(void)
{
int n, k;
scanf("%d%d", &n,&k);
//Input: 3 2 output: 3
//Input: 30 10
//output: -108
printf("%d",cnk(n,k));
return 0;
}