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

Function sqrt

code/mathematics/ntt.cpp:44–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 rep(i,0,l<<1) y[i] = y[i]*2 - T1[i] * y[i] * y[i];
43 ntt(y, l<<1, true); }
44void sqrt(Num x[], Num y[], int l) {
45 if (l == 1) { assert(x[0].x == 1); y[0] = 1; return; }
46 sqrt(x, y, l>>1);
47 inv(y, T2, l>>1);
48 rep(i,l>>1,l<<1) T1[i] = T2[i] = 0;
49 rep(i,0,l) T1[i] = x[i];
50 ntt(T2, l<<1); ntt(T1, l<<1);
51 rep(i,0,l<<1) T2[i] = T1[i] * T2[i];
52 ntt(T2, l<<1, true);
53 rep(i,0,l) y[i] = (y[i] + T2[i]) * inv2; }
54// vim: cc=60 ts=2 sts=2 sw=2:

Callers 10

intersectFunction · 0.85
tangentFunction · 0.85
cmpslFunction · 0.85
lengthMethod · 0.85
distMethod · 0.85
distMethod · 0.85
rebuildFunction · 0.85
dist_toMethod · 0.85
testFunction · 0.85
is_squareFunction · 0.85

Calls 2

invFunction · 0.85
nttFunction · 0.85

Tested by 2

dist_toMethod · 0.68
testFunction · 0.68