Skip to content

Instantly share code, notes, and snippets.

@Chillee
Created July 31, 2018 00:47
Show Gist options
  • Select an option

  • Save Chillee/75426f90d9ddcd8dec8ea98dfe7a8d53 to your computer and use it in GitHub Desktop.

Select an option

Save Chillee/75426f90d9ddcd8dec8ea98dfe7a8d53 to your computer and use it in GitHub Desktop.
SOS DP (Sum over Subsets DP)
int F[1 << MAXBITS];
for (int i = 0; i <= MAXBITS; ++i) {
for (int mask = 0; mask < (1 << MAXBITS); ++mask) {
if (mask & (1 << i)) {
F[mask] = max(F[mask], F[mask ^ (1 << i)]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment