Lowest Bit
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 9052 Accepted Submission (s): 6656
Problem Descriptiongiven an positive integer a (1 <= a <=), output the lowest bit of a.
For example, given a = +, we can write a in binary form as 11010, so the lowest bit of a is ten, so the output should be 2 .
Another example goes like this:given a = to, we can write A in binary form as 1011000, so the lowest bit of The output should is 8.
Inputeach 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.
Outputfor each A in the input, output A line containing only it lowest bit.
Sample Input
26880
Sample Output
28
Authorshi, Xiaohan, the grass in the big night.
#include <iostream> #include <cmath>using namespace Std;int main () {int A;while (cin>>a,a) {int count=0 ; while (a%2==0) {count++;a/=2;} Cout<<pow (2,count) <<endl;} return 0;}
Hangzhou Electric HDU 1196 Lowest Bit