아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Modified Gray Code

시간 제한2초메모리 제한1024 MB

요약
각 단계에서 짝수 개의 비트를 뒤집고 아직 쓰지 않은 가장 작은 값을 고르는 10비트 even Gray code의 각 항목을 구한다.
난이도

보통10점 중 6점

유형
비트 연산, 그리디, 완전 탐색
정답자
아직 제출이 없습니다

문제

The Gray Code is a well-known binary sequence in which successive elements differ by only one bit, and the bit chosen to be switched yields the smallest normal binary value not yet used. The first element of the sequence is the binary sequence corresponding to 0. For example, the 3-bit Gray Code sequence is 000, 001, 011, 010, 110, 111, 101, 100. So the element at index 0 is 000, the element at index 4 is 110, and so on.

We want to modify the Gray Code so that successive elements differ by an even number of bits, but again the bits selected to be changed should yield the smallest normal binary value not yet used. We call this the even Gray code. Here are the first 3 elements of the 5-bit even Gray Code:

0   0 0 0 0 0
1   0 0 0 1 1     (2 bits switched – positions 1 and 2)
2   0 0 1 0 1     (2 bits switched – positions 2 and 3)

Given an index KK, give the element at index KK in the 10-bit even Gray Code.

입력

The first line of input consists of an integer NN (1≤N≤5001\le N\le 500), which is the number of queries that will be made. The remaining NN lines each contains a positive integer KK (1≤K≤5001 \leq K \leq 500) representing the index of the 10-bit even Gray Code.

출력

For each input query, print the 10-bit representation of the corresponding even Gray Code element. There may be leading 0's but there should be no spaces between the digits.

예제2

  1. 예제 1

    입력
    1
    2
    
    예상 출력
    0000000101
    
  2. 예제 2

    입력
    2
    1
    10
    
    예상 출력
    0000000011
    0000010100