9-degree OJ--Q1473, 9-degree oj

Source: Internet
Author: User

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 ();

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.