Input set size N (≤12). Visualize all 2^N bitmasks, submask iterations, and generate ready-to-paste C++ DP skeleton.
Yes, completely free. No sign-up, no credit card, no usage limits.
Never. Everything runs 100% in your browser. Nothing is uploaded to any server.
Yes. All tools are fully responsive and work on phones, tablets, and desktops.
Total masks
8
Submask iterations
3n
All Bitmasks
Click a mask to see its submasks
| Mask | Binary | Set Bits | |S| |
|---|---|---|---|
| 0 | 000 | {} | 0 |
| 1 | 001 | {0} | 1 |
| 2 | 010 | {1} | 1 |
| 3 | 011 | {0, 1} | 2 |
| 4 | 100 | {2} | 1 |
| 5 | 101 | {0, 2} | 2 |
| 6 | 110 | {1, 2} | 2 |
| 7 | 111 | {0, 1, 2} | 3 |
C++ Bitmask DP Template
// Bitmask DP skeleton for N = 3
// Total masks: 8
#include <bits/stdc++.h>
using namespace std;
const int N = 3;
int dp[1 << N];
void solve() {
// Iterate over all masks
for (int mask = 0; mask < (1 << N); mask++) {
// __builtin_popcount(mask) = number of set bits
int bits = __builtin_popcount(mask);
// Submask iteration for mask = m
// for (int s = mask; s > 0; s = (s-1) & mask) { ... }
// Example: dp transition
dp[mask] = 0; // TODO: fill your logic
}
}
int main() {
int n; cin >> n;
solve();
}