組合數求計算總結(模板)

  一.一般粗暴法 用普通的組合公式來算 當求C(n,m)%MOD時容易超範圍,因爲這種方法計算有除法,不能邊做邊MOD. 優點:複雜度O(n),缺點只能求n,m極小的情況。 #include<bits/stdc++.h> #define ll long long using namespace std; const ll MOD = 1e9 + 7; ll cal(int n,int m) {
相關文章
相關標籤/搜索