
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=1196
Lowest Bit
Description
Given an positive integer $A (1 \leq A \leq 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$.
Input
Each line of input contains only an integer $A (1 \leq A \leq 100).$ $A$ line containing $"0"$ indicates the end of input, and this line is not a part of the input data.
Output
For each A in the input, output a line containing only its lowest bit.
Sample Input
26
88
0
Sample Output
2
8
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
using std::set;
using std::map;
using std::cin;
using std::cout;
using std::endl;
using std::find;
using std::sort;
using std::pair;
using std::vector;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define iter(c) decltype((c).begin())
#define cls(arr,val) memset(arr,val,sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
const int Max_N = ;
typedef unsigned long long ull;
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int n, ans;
while (~scanf("%d", &n) && n) {
ans = ;
while (true) {
if (n & ) break;
ans <<= ;
n >>= ;
}
printf("%d\n", ans);
}
return ;
}