21006_OuroborosSnake

2022-5-16 18:18| 发布者: Hocassian| 查看: 51| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504747493000-Problem List-采集的数据-后羿采集器.html

Pro.ID

21006

Title

Ouroboros Snake

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21006

AC

8

Submit

15

Ratio

53.33%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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 2n bits that have the property of "generating" the whole set of numbers from 0 to 2n - 1. The generation works as follows: given an Ouroboros number, we place its 2n bits wrapped in a circle. Then, we can take 2n 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 < 2n ). The end of the input file is indicated by a line containing two zeros. Don't process that line.

    输出

    Description

    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 2n bits that have the property of "generating" the whole set of numbers from 0 to 2n - 1. The generation works as follows: given an Ouroboros number, we place its 2n bits wrapped in a circle. Then, we can take 2n 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.
    Input

    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 < 2n ). The end of the input file is indicated by a line containing two zeros. Don't process that line.

    Output

    For each test case, output o(n, k) on a line by itself.

    Sample Input

    2 0
    2 1
    2 2
    2 3
    0 0

    Sample Output

    0
    1
    3
    2

    Source

    样例输入

    2 0
    2 1
    2 2
    2 3
    0 0

    样例输出

    0
    1
    3
    2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部