eolymp
bolt
Try our new interface for solving problems
Problems

Matrix Cypher

Matrix Cypher

Alice and Bob communicate via a matrix channel. Alice wants to send a message to Bob. She has a bitstring representing her message and performs a bitwise encoding algorithm: She starts with the identity matrix $$ A = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} $$ and then reads the bitstring starting from the left-most bit. For each $0$-bit she multiplies the matrix $A$ from the right with $$ \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix}, i.e.~A = A \cdot \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix} $$ For each $1$-bit she multiplies the matrix $A$ from the right with $$ \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}, i.e.~A = A \cdot \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} $$ Then the result is transmitted. Now Bob accidentally deleted the software to decrypt a message from Alice. Can you help him to rewrite it? \InputFile Consists of two lines, the $i$-th of them with two integers $a_{i_1}$ and $a_{i_2}~(0 \le a_{i_1}, a_{i_2} \le 2^{128} - 1$ for all $i~(1 \le i \le 2)$, where $$ A = \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix} $$ is the matrix containing the encoded message. The bitstring representing the message consists of at most $120$ characters. \OutputFile Output the decoded bitstring.
Time limit 1 second
Memory limit 128 MiB
Input example #1
2 1
3 2
Output example #1
010
Input example #2
18 29
13 21
Output example #2
10010101
Source 2016 German Collegiate Programming Contest (GCPC), Problem D