MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / Num

Class Num

code/mathematics/ntt.cpp:6–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4 inv2 = mod_pow<ll>(2, mod-2, mod);
5#define MAXN (1<<22)
6struct Num {
7 int x;
8 Num(ll _x=0) { x = (_x%mod+mod)%mod; }
9 Num operator +(const Num &b) { return x + b.x; }
10 Num operator -(const Num &b) const { return x - b.x; }
11 Num operator *(const Num &b) const { return (ll)x * b.x; }
12 Num operator /(const Num &b) const {
13 return (ll)x * b.inv().x; }
14 Num inv() const { return mod_pow<ll>((ll)x, mod-2, mod); }
15 Num pow(int p) const { return mod_pow<ll>((ll)x, p, mod); }
16} T1[MAXN], T2[MAXN];
17void ntt(Num x[], int n, bool inv = false) {
18 Num z = inv ? ginv : g;
19 z = z.pow((mod - 1) / n);

Callers 2

berlekamp_masseyFunction · 0.85
nttFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected