HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Chapter 3. Repetition structures > problem:


09. Decimal to binary

Guest
• Review clarifications (1)

Volume problems

• Sum of N numbers
• 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
• The power of 2

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

Make a program that gets a decimal number and prints its binary equivalent as output.

To convert a decimal number to its binary equivalent you can use the "short division by 2 remainder" method. This method relies only on division by two.

For example, let's convert the decimal number 156 to binary. Write the decimal number on the first line.
156
Divide it by 2 and write the integer answer (quotient) under it, and write the remainder (0 or 1) to the right of it.
156 0
78

Continue downward, dividing each new quotient by two and writing the remainders to the right of them. Stop when the quotient is 0.

156
78
39
19
9
4
2
1
0
0
0
1
1
1
0
0
1

Starting with the bottom-most remainder 1, read the sequence of 1's and 0's upwards to the top. You should have 10011100. This is the binary equivalent of the decimal number 156.

Input

A single integer N (0 ≤ N < 264).

Output

Print binary equivalent of given decimal number.

Example

stdin stdout

6

110

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

www.contester.ru