Skills101
← All coding problems

Decimal to Binary

easyPlacement Coding+10 XPTime limit 2s

Convert each number to binary (base 2), without leading zeros. 10 is 1010; 0 is 0.

Input:

  • line 1: q
  • next q lines: one integer n

Output: q lines — each number in binary.

Constraints: 1 ≤ q ≤ 10⁴, 0 ≤ n ≤ 10¹⁸.

Think about it: divide by 2 repeatedly; the remainders, read from last to first, are the binary digits. Remember the special case n = 0.

Sample input 1

3
10
0
255

Sample output 1

1010
0
11111111

Sample input 2

2
1
2

Sample output 2

1
10

Read input from standard input and print the answer to standard output. Your code runs in a secure sandbox against the samples (Run) and hidden tests (Submit).

Loading editor…

Log in to run and submit your code — it's free.