BitBitJump
시간 제한3초메모리 제한2048 MB
16비트 IO 워드가 주어진 값 x와 같은지 검사하는 BitBitJump 프로그램을 만들어 16진수 덤프로 출력한다.
문제
BitBitJump is a one instruction set computer. Thus, it has only one instruction: bbj a, b, c, which copies an -th bit of memory to the -th bit of memory and then jumps to address .
Let's consider a 16-bit BitBitJump computer. It has bits of memory organized in 16-bit words. Words are counted from 0, and bits in a word are counted from the least significant (0-th) bit to the most significant (15-th) bit.
This computer has a single instruction pointer register , and execution starts with . If the current , the computer stops. Otherwise, it uses the -th word as , the -th word as , the -th word as , and performs the bbj a, b, c instruction: copies the (a \mathbin{\\&} 15)-th bit of the -th word to the (b \mathbin{\\&} 15)-th bit of the -th word, and sets . Here, '\mathbin{\\&}' represents bitwise AND, and '' represents bitwise shift right operation. Notice that the value of is read from memory after the bit copy, so if the instruction modified its own , the new value will be used for .
For example, the bbj 32, 35, 5 instruction placed at the memory start will be executed as follows:
- and are read from the memory.
- The 0-th bit of the 2-nd word (its value is 5 \mathbin{\\&} 1 = 1) will be copied to the 3-rd bit of the same word, so the 2-nd word will have the value of .
- Then is read from memory, and is set to 13.
Let's call the -th word (-th bits of memory) an IO-word. An -comparator is a program which checks whether the value of the IO-word is equal to . It should stop after execution of no more than instructions, leaving the lowest bit of the IO-word equal to if the original value of the IO-word was equal to , and otherwise.
Write a program that generates an -comparator for the given value of .
입력
The input contains a single decimal integer () --- the value for which to build the \nobreakdash-comparator.
출력
The output should contain the -comparator program dump. Dump consists of values for the first words of the memory (). All other words, except the IO-word, are filled with zeroes.
For each of the words, output its value as a four-character hexadecimal number. Values should be delimited by space or new line characters.
힌트
A dump in the sample output contains a 0-comparator. It consists of the following blocks:
- 16 instructions: the -th of them, counting from 0, copies the -th bit of the input word to the 6-th bit of its own . If the copied bit is zero, it will proceed to the next instruction; otherwise, the next instruction number will be increased by 64.
- The following instruction copies the 4-th bit of the 0-th word (value 1) to the 0-th bit of the IO-word and jumps to the stop address.
- 16 unused words filled with 0.
- 16 equal instructions (starting from word 67). Each of them copies the 0-th bit of the 0-th word (value 0) to the 0-th bit of the IO-word and jumps to the stop address.