ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Chapter 3. Repetition structures > задача:


08. Binary to decimal

Задачи сборника

• Sum less than N
• Sum of N numbers
• 01. How many digits?
• 02. How many divisors?
• 04. Поезд
• 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
• Степень двойки

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 1000/1000/1000/1000 мс. Лимит памяти 65000/65000/65000/65000 Кб.

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