可云谁来救我表情包:有段英文程序帮忙翻译

来源:百度文库 编辑:高校问答 时间:2024/04/27 15:25:02
ACM浙大在线答题,可我连题目都看不懂!谢谢你们帮我翻译下!
忘了写英文了:
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

一个旅行者计划在n座城市之间旅游一趟,此处n是2的幂次方,这时我们用数值0到n-1简单标记这n座城市.这个旅行者住在这n座城市的其中之一,那是他旅行的始发地也是终点地.他只能访问每座城市一次,因为某种特殊的原因,在他旅行中两座相邻的城市必须满足一个等式(即标记这两个城市的数值假定为A,B.AB必须满足A 异或 B 的结果同样是2的幂次方).以为他这个想法很奇怪,所以没有旅行社愿意提供帮助,最后他找到你请你提供一个解决的方法.如果可以解决请给出解决的方法,如果不能解决请告诉他这个旅行的安排是不可能实现的.
输入
输入有两个整型数 n 和 m, n 代表城市的总个数,m 数值代表他所居住的城市.
程序要求能处理多次输入情况,直到你输入的n=0;
输出
打印"NO"(即该安排不能实现时)或一行以空格相隔的城市标记(即旅行的顺序).
示例输入
2 1
4 0
0 0
示例输出
1 0
0 1 3 2

备注:本人觉得该题是条件受限的完全无向图遍历问题