Octal
InterviewTime limit1sMemory limit128 MB
Convert a binary string (up to 100 digits) to octal by padding and grouping bits in threes using the given table.
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
A positive integer is written in binary. Convert it to octal by using the following method.
- Add
0characters to the front until the length of the binary string is a multiple of 3. - Split the string into groups of three digits from left to right.
- Replace each three-digit binary group with one octal digit according to the table below.
Given the binary number, print its octal representation.
Input
The first line contains a binary number. Its length is between 1 and 100, inclusive, and its first character is 1.
Output
Print the converted octal number on one line.