How do I find all natural numbers k satisfying k & x == k for some Natural Number x? asked 16 Jan, 17:03

You can just go through the suboptimal solution mentioned here: answered 16 Jan, 18:20

you can convert the number x into binary form i.e 15=1+2+4+8 and 13=1+4+8 and make array of all these numbers i.e array for 15={1,2,4,8} and array for 13 will be {1,4,8} and the find the subsets of this array... and just add elements of each of them.. so 15 will update all elements from 1 to 15 as all numbers can be computed using elements of that array.. EDIT: well, there may be another optimised soln about which i am not aware answered 16 Jan, 23:47

SOS dp. Read the codeforces article.