The Inverse Fast Möbius Transform is an algorithm that finds a function such that in time and space.

Algorithm

Lemma

is a function such that .

  1. Apply the Fast Möbius Transform to find for each subset of .
  2. Apply the lemma to find .

This algorithm solves the problem in time and space.

void ifmt(int n, std::vector<int> &a) {
	for (u32 s = 0u; s < 1u << n; s++) {
		if (std::popcount(s) % 2 == 1) {
			a[s] *= -1;
		}
	}
	fmt(n, a);
	for (u32 s = 0u; s < 1u << n; s++) {
		if (std::popcount(s) % 2 == 1) {
			a[s] *= -1;
		}
	}
}