We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3d2d5f5 commit c2d46cfCopy full SHA for c2d46cf
library/math/n_choose_k/grow.hpp
@@ -5,9 +5,8 @@ struct comb {
5
};
6
vector<comb> t(2);
7
void grow(int n) {
8
- while (sz(t) <= n) {
9
- ll i = sz(t),
10
- inv = mod - (mod / i) * t[mod % i].inv % mod;
+ rep(i, sz(t), n + 1) {
+ ll inv = mod - (mod / i) * t[mod % i].inv % mod;
11
t.push_back({inv, i * t[i - 1].fact % mod,
12
inv * t[i - 1].inv_fact % mod});
13
}
0 commit comments