// n 个 数 取 k个数的取法
// C(n,k) 注意些细节
#include <iostream> #include <string> #include<sstream> #include <cmath> #include <map> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define LL long long LL C(int n,int k) { LL m=1; if(k>n/2) k=n-k; // 不加这句会超时 比如C[10^9][10^9 - 1] int i; for(i=1;i<=k;i++) { m*=(n-i+1); m/=i; } return m; } int main() { int n,k; while(scanf("%d %d",&n,&k),n|k) { printf("%lld\n",C(n,k)); } return 0; }

 

相关文章:

  • 2021-08-15
  • 2021-04-29
  • 2022-12-23
  • 2021-08-09
  • 2021-10-25
  • 2021-10-20
  • 2021-10-06
  • 2021-10-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2022-02-26
  • 2021-05-19
  • 2021-11-09
  • 2022-01-28
相关资源
相似解决方案