Problem B
Decimal-To-Binary Conversions
Problem Description:
Robin and Arif
are two friend. They took admission at BUBT. Robin took admission at CSE
program and Arif took admission at BBA program. Robin studied CSE 101 (Computer
Fundamentals) at first semester. Arif took CIS 101 (Introduction to Computer
Science) at second semester. Arif faced some problems when he was studying
Binary Conversion. He decided to take help from Robin. Arif discussed his
problem with Robin. After the discussion Robin decided that he would write a
program that will be to convert Decimal Number to its equivalent Binary Number
and gave this program to arif to check his answer(Conversion done by Arif) with
this program output to sure is the Conversion done by Arif is correct or not.
Input:
Each test case contains one line.
The line contain decimal number P(1<=P<=200) as input. The number must be
integer number.
Output:
You will have to
output the equivalent binary number in one line.
Sample Input
|
Sample Output
|
25
37
|
11001
100101
|
Hint: There are two ways to convert a
decimal whole number to its equivalent binary system representation. One way is
repeatedly dividing the decimal number by 2 and write down the remainder after
each division until a quotient of 0 is obtained. Note that the binary result is
obtained by writing the first remainder as the LSB and the last remainder as
the MSB.
For example:
25
|
=12+ remainder of 1
|
2
|
|
12
|
=6+ remainder of 0
|
2
|
|
6
|
=3+ remainder of 0
|
2
|
|
3
|
=1+ remainder of 1
|
2
|
|
1
|
=0+ remainder of 1
|
2
|
|
2510= 1 1 0 0 1
For Div.1, solve this problem with
ReplyDelete0 <= P <= 200000