Generating a wanted number by bitwise OR
问题 Given N integer intervals [lo_i,hi_i]. From each interval chose a number such that bitwise OR of them become given number X.(It doesn't matter if the result has more 1 bits than X; i.e. if the generated number is Y, (X&Y)==X should hold) 回答1: I guess this problem is NP complete, though I haven't found an NP hard problem easily reducible to this. But for those sets that contain 2^(mostSignificantDigit) - 1, I would do as a heuristic: Firstly, try the number 1...1 (mostSignificantDigit-1 ones),