
ZOJ Problem Set  2531
A traveller plans a round trip through n cities, where n is a power of 2, in which case we simply index them with numeric values from 0 to n  1. The traveller lives in one of them, and that's where he will start and end his trip. He only visits each city once, and for some particular reason the two adjacent cities on his trip should satify an equation that (A xor B) is also a power of 2. For his odd mind no travel agency is willing to offer any help and finally he comes to you for a solution. You would either tell him it's not possible to arrange a trip for him. Input Input has two integers n and m, which are respectively the number of cities and the city he lives in. Proceed through multiple cases until you meet a case n = 0. Output Print "NO" or a list of n city numbers on a single line separated by a single space. Sample Input2 1 4 0 0 0Sample Output 1 0 0 1 3 2 Author: WU, Jiazhi Source: CYJJ's Funny Contest #3, Having Fun in Summer 