[n+1][1024]
where n
is the length of nums
.dp[n][0]
to 1, representing the empty subset.nums
in reverse.dp[i][mask]
by adding dp[i+1][mask]
(excluding the current element).dp[i][mask]
by adding dp[i+1][new_mask]
where new_mask
includes the prime factors of the current element.dp[0][0] - 1
to exclude the empty subset.