DSA
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
350 B

  1. #include <bits/stdc++.h>
  2. using namespace std ;
  3. long long c[200][20000] ;
  4. main()
  5. {
  6. freopen("combination.in","r",stdin) ;
  7. freopen("combination.out","w",stdout) ;
  8. int n , k ;
  9. cin >> n >> k;
  10. for(int i = 0 ; i <= n ; ++i)
  11. {
  12. c[i][0] = 1 ; c[i][i] = 1 ;
  13. for(int j = 1 ; j < i ; ++j)
  14. c[i][j] = c[i-1][j-1]+c[i-1][j] ;
  15. }
  16. cout << c[n][k] ;
  17. }