ЕГЭ
Time limit4sMemory limit1024 MB
Given k and i, print the seven characters of the k-th string S_k starting at position i, where the strings follow the Thue-Morse doubling rule.
- Level
Medium4 of 10
- Topics
- Bit manipulation, Math
- Solved
- No attempts yet
Problem
Igor loved computers since childhood. He played games on them, watched movies, and did many other enjoyable things. Sometimes he even wrote programs. He dreamed of getting into university and becoming a programmer. But Igor was not a very diligent student, so the day of the ЕГЭ informatics exam came as a complete surprise. Without a good ЕГЭ score, the dream will remain just a dream.
On a practice ЕГЭ, he got a task he did not know how to solve. The task asked for seven consecutive characters of the -th string, starting from the -th character. The strings are built by these rules:
- , where is the string with all zeros replaced by ones and all ones replaced by zeros.
Igor asks you to help him solve this problem.
Input
The input file contains two integers and (, ).
Output
Print the seven characters of the -th string, starting from the -th character.