Lowest Bit
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 9273 Accepted Submission (s): 6824
Problem Description
Given 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.
Input
Each line of input contains is 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.
Output
For each of a in the input, output A line containing only its lowest bit.
Sample Input
26
88
0
Sample Output
2
8
Test instructions: Output converted to binary non-0-bit
Code:
#include <cstdio>#include <iostream>usingnamespacestd;int main(){ int a; while(cin >>a, a){ cout << (a&(-a)) <<endl; } return0;}
Hdoj 1196 Lowest Bit "&"