## Binary

View as PDF

Points:5
Time limit:2.0s
Memory limit:64M
Author:

Problem types

Your computer science teacher has kindly requested that you write a program to convert a number, inputted in decimal, to binary to help in teaching students about binary. Also to aid in human processing of numbers, you should group every four bits and separate the groups by space.

#### Input Specification

The first line will be integer (), the number of numbers to convert to binary. The next lines will be such that ().

#### Output Specification

For every integer , output the binary representation, grouped into four bit groups, separated by spaces. If necessary, you must pad the first group to have exactly four bits.

#### Sample Input

3
1
10
255


#### Sample Output

0001
1010
1111 1111


• Shehryar
commented on Jan. 2, 2017, 1:03 a.m.
Hint

Java has a method you can call against the Integer class: Integer.toBinaryString(number);

• acetao
commented on Jan. 27, 2016, 1:04 a.m. edit 3
output must be a group with four digits

Note the output specification: (1) 16 --> 10000,output should be:
0001 0000,output should not be:1000 0 (2) 0 --> 0000,1 --> 0001, 7 --> 0111

• Ish_God
commented on Nov. 15, 2015, 6:28 p.m.
OLE

what is the output if the input is 0

• Xyene
commented on Nov. 15, 2015, 7:04 p.m.
0000

• niamp
commented on Nov. 10, 2015, 10:44 p.m. edited

I tested my solution using eclipse and all the test cases are correct, why am I getting WA in my submissions?

UPDATE: Nvm, I was making a stupid mistake

• Anix55
commented on Oct. 24, 2015, 11:35 p.m.
help pls

I can't get the first text case to work...is anyone having a similar problem?