编程介的小学生 2017-03-27 13:04 采纳率: 0.2%
浏览 754
已采纳

Traveller

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 Input
2 1
4 0
0 0
Sample Output
1 0
0 1 3 2

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-04-05 15:39
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 (SQL语句|查询结果翻了4倍)
  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用
  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊