Logo
(追記) (追記ここまで)

6330번 - Ouroboros Snake 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB63360.000%

문제

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.

출력

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

제한

예제 입력 1

2 0
2 1
2 2
2 3
0 0

예제 출력 1

0
1
3
2

힌트

출처

ICPC > Regionals > Europe > Mid-Central European Regional Contest > MCERC 2000 E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /