MCPcopy Create free account
hub / github.com/ShahjalalShohag/code-library / exp

Method exp

Math/Subset Sum Problem.cpp:222–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220 return (differentiate().mod_xk(n) * inverse(n)).integrate().mod_xk(n);
221 }
222 poly exp(int n) const { //e ^ p(x) mod x^n
223 if(is_zero()) return {1};
224 assert(a[0] == 0);
225 poly ans({1});
226 int i = 1;
227 while(i < n) {
228 poly C = ans.log(2 * i).div_xk(i) - substr(i, 2 * i);
229 ans -= (ans * C).mod_xk(i).mul_xk(i);
230 i *= 2;
231 }
232 return ans.mod_xk(n);
233 }
234};
235// number of subsets of an array of n elements having sum equal to k for each k from 1 to m
236int32_t main() {

Callers 1

mainFunction · 0.45

Calls 5

is_zeroFunction · 0.85
div_xkMethod · 0.45
logMethod · 0.45
mul_xkMethod · 0.45
mod_xkMethod · 0.45

Tested by

no test coverage detected