排列組合模板

求排列組合數。 //n > r //求排列數 int getA(int n, int r){ int ans = 1; for(int i = 0; i < r; ++i) ans *= n-i; return ans; } //求組合數 int getC(int n, int r){ int ans = 1; for(int i = 1;
相關文章
相關標籤/搜索