当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1392:Ouroboros Snake

题目描述
Ouroboros is a mythical snake from ancient Egypt. It has its tail in its mouth and continously devours itself.

The Ouroboros numbers are binary numbers of 2^n bits that have the property of "generating" the whole set of numbers from 0 to 2^n - 1. The generation works as follows: given an Ouroboros number, we place its 2^n bits wrapped in a circle. Then, we can take 2^n groups of n bits starting each time with the next bit in the circle. Such circles are called Ouroboros circles for the number n. We will work only with the smallest
Ouroboros number for each n.

Example: for n = 2, there are only four Ouroboros numbers. These are 0011;0110;1100; and 1001. In this case, the smallest one is 0011. Here is the Ouroboros circle for 0011:

The table describes the function o(n;k) which calculates the k-th number in the Ouroboros circle of the smallest Ouroboros number of size n. This function is what your program should compute.
输入解释
The input consists of several test cases. For each test case, there will be a line containing two integers n and k (1<=n<=15; 0<=k<2^n). The end of the input file is indicated by a line containing two zeros. Don抰 process that line.
输出解释
For each test case, output o(n;k) on a line by itself.
输入样例
2 0
2 1
2 2
2 3
0 0
输出样例
0
1
3
2

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-1392

最后修改于 2020-10-29T06:02:48+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536