(HDU simple question 128) Lowest Bit



Lowest Bit

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8722    Accepted Submission(s): 6428

Problem Description
Given an positive integer A (1 <= A <= 100), output the lowest bit of A.

For example, given A = 26, we can write A in binary form as 11010, so the lowest bit of A is 10, so the output should be 2.

Another example goes like this: given A = 88, we can write A in binary form as 1011000, so the lowest bit of A is 1000, so the output should be 8.

Each line of input contains only an integer A (1 <= A <= 100). A line containing “0” indicates the end of input, and this line is not a part of the input data.

For each A in the input, output a line containing only its lowest bit.

Sample Input
26 88 0

Sample Output
2 8

SHI, Xiaohan


Ignatius.L   |   We have carefully selected several similar problems for you:  

Title analysis:

Simple questions. In the process of converting 10 -in -production numbers into 2nd -in numbers, you can constantly determine whether the current bit is non -zero.

corresponding knowledge points:

At this time, you may need to review the process of 10 -in -proof and two -in -making process:

code is as follows:

  * D.CPP 
  * Created on: March 11, 2015 
  * Author: administrator 

 #include <iOSTREAM> 
 #include <cstdio> 
 #include <cmath> 

 using namespace std; 

 int Main () { 
 int n; 
 While (scanf ("%d", & n)! = EOF, N) { 

 int T = 0; 
 While (n%2 == 0) {{ 
 t ++; 
 n /= 2; 

 Printf ("%d \ n", (int) pow (2+0.0, t)); 

 Return 0; 


Random Posts

linux debian Set up and start boot

MAC installation Metasploit

How to use the plug -in Swiper

[Free] Xiaomi Instant Message Cloud MIMC Introduction -Free, Simple Implementation IM

JUNIT’s Basic Explanation II