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

Function sieve

code/mathematics/mertens.cpp:12–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10 ans += mer[i] * (n/i - max(done, n/(i+1)));
11 return mem[n] = 1 - ans; }
12void sieve() {
13 for (int i = 1; i < L; i++) mer[i] = mob[i] = 1;
14 for (int i = 2; i < L; i++) {
15 if (mer[i]) {
16 mob[i] = -1;
17 for (int j = i+i; j < L; j += i)
18 mer[j] = 0, mob[j] = (j/i)%i == 0 ? 0 : -mob[j/i]; }
19 mer[i] = mob[i] + mer[i-1]; } }
20// vim: cc=60 ts=2 sts=2 sw=2:

Callers 2

testFunction · 0.70
testFunction · 0.70

Calls

no outgoing calls

Tested by 2

testFunction · 0.56
testFunction · 0.56