HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Chapter 3. Repetition structures > problem:


08. Binary to decimal

Volume problems

• Sum of N numbers
• The power of 2
• 01. How many digits?
• 02. How many divisors?
• 04. Train
• 05. Factorial
• 06. X to the power of Y
• 07. Fibonacci Series
• 08. Binary to decimal
• 09. Decimal to binary
• 10. Maximum
• 11. Perfect numbers
• 12. Wonder primes
• 13. Round numbers
• 14. Tower of Happiness
• 2. Molecules

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 1000/1000/1000/1000 ms. Memory limit 65000/65000/65000/65000 Kb.

Problem description

Binary is a number system used by digital devices like computers. The computer represents values using two voltage levels (usually 0V and +5V). With two levels we can represent exactly two different values. These could be any two different values, but by convention we use the values zero (0) and one (1).
It is very simple to convert binary into decimal. Just like the decimal system, we multiply each digit by its weighted position, and add each of the weighted values together. For example, the binary value 10011101 represents:
1*27 + 0*26 + 0*25 + 1*24 + 1*23 + 1*22 + 0*21 + 1*20 = 157.
Make a program that gets a binary number and prints its decimal equivalent as output.

Input

A nonempty sequence of 1 and 0 which length is not bigger then 64.

Output

Print decimal equivalent of given binary number.

Example

stdin stdout

110

6

10011101 157
Для отправки решений необходимо выполнить вход.

www.contester.ru