9-degree OJ--Q1473, 9-degree oj
Import java. util. ArrayList;
Import java. util. collections;
/*
* Description:
* As we all know, data is stored in binary format in computers.
* One day, after learning the C language, James wants to know what a binary string stored in a computer looks like, a number of the unsigned int type.
* Can you help James? In addition, James does not want to remove the leading 0 from the binary string.
* Input:
* In the first row, a number T (T <= 1000) indicates the number of numbers required below.
* Next, there are T rows. Each row has a number n (0 <= n <= 10 ^ 8), indicating the required binary string.
* Output:
* T rows are output. The binary string obtained from the output of each row.
* Example input:
* 5
* 23
* 535
* 2624
* 56275
* 989835
* Sample output:
* 10111
* 1000010111
* 101001000000
* 1101101111010011
* 11110001101010001011
*/
Public class q1473 {
Public static void main (String [] args ){
Required bytes = new bytes (System. in );
Int T = response. nextInt ();
Int [] pre = new int [T];
For (int m = 0; m <T; m ++ ){
Pre [m] = response. nextInt ();
}
For (int m = 0; m <T; m ++ ){
Int n = pre [m];
ArrayList <Integer> a = new ArrayList <Integer> ();
// Consider the case where the input integer is 0
If (n = 0 ){
System. out. println ("0 ");
Continue;
}
Else {
While (n! = 0 ){
A. add (n % 2 );
N = n/2;
}
Integer target [] = new Integer [a. size ()];
Target = a. toArray (target );
For (int I = target. length-1; I> = 0; I --){
System. out. print (target [I]);
}
System. out. println ();
}
}
Response. close ();
}
}