2018 Java Chapter 5 (Week 05)

From: 2018-09-01 00:00:00 To: 2018-11-13 00:00:00 Now: 2024-11-23 18:39:18 Status: Public

L - 2진표현

Time Limit: 1s Memory Limit: 128MB

Submissions: 919 Solved: 489
Description

Short 범위에 해당되는 값을 입력 받아, binary로 출력하는 프로그램을 작성하세요.

A short value S is stored in 16 bits. Write a program that prompts the user to enter a short integer and displays the 16 bits for the integer.

Input

* Line 1 : 테스트케이스 T (1~1,000)

* Line 2 ~ T+1 : S (-32,768~32,767)

 

Output

* Line 1 ~ T : S에 대한 bit 표현

 

Sample Input
2
5
-5
Sample Output
0000000000000101
1111111111111011
Hint

You need to use the bitwise right shift operator (>>) and the bitwise AND operator (&), which are covered in Appendix G, Bitwise Operations.

Source

JAVA2015 PE5.44