Has Not Appeared

Prefix Sums of Multiplicative Functions

Author: Benjamin Qi


Edit This Page

Linear Time Sieve

Counting Primes

Totient Function

template<int SZ> struct Sieve {
vi pr;
int sp[SZ], phi[SZ]; // smallest prime that divides
Sieve() { // above is faster
memset(sp,0,sizeof sp);
phi[1] = 1;
FOR(i,2,SZ) {
if (sp[i] == 0) {
sp[i] = i, pr.pb(i); phi[i] = i-1;
} trav(p,pr) {

(project euler)

(topcoder problem)

Module Progress:

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!