[USACO 2010 Mar B]Hexadecimal Conversion
题号:NC24729
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
64bit IO Format: %lld

题目描述

Bessie was teaching Jessie, her protege interesting in programming contests the binary facts of life. She explained that computers work in binary (base 2) and that all computer numbers in general are stored as 0's and 1's. Jessie was a bit unclear on the concept, so Bessie made her an exercise, shown below.
Write a program that converts an unsigned hexadecimal number to octal (base 8) form. Hexadecimal number can have at most 100,000 digits and is composed of digits and capital letters from A to F.
Note: a hexadecimal number is a special way of representing numbers in base 16. The digits 0-9 still correspond to 0-9, and then A (capital A!) corresponds to 10, B to 11, etc. (F stands for 15).
For example, the hexadecimal number A10B corresponds to the (decimal) number . The corresponding octal (base 8) number would be 120413, since .
Hint: there is an easier way to convert from hexadecimal to octal than by converting hexadecimal -> decimal -> octal. It might help to think about the numbers in binary (base 2).

输入描述:

* Line 1: A single hexadecimal number. Multidigit numbers will have no leading zeroes (i.e., A1 instead of 00A1). 0 (by itself) is a valid input.

输出描述:

* Line 1: The octal value with no leading zeros.  If the input is 0, the output should also be 0.
示例1

输入

复制
123ABC

输出

复制
4435274