题目连接

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 ;
}

最新文章

  1. -XX:+printGC
  2. linux下文件编码的查看与修改
  3. h5-2
  4. 教了几天C语言 C语言竞赛------家长们你们为什么这么急!!
  5. 每天一个linux命令:mkdir
  6. Android_按钮被按下效果的实现(selector选择器)
  7. Docker简明教程(转)
  8. Secondary Namenode - What it really do?
  9. 1132: 零起点学算法39——多组测试数据(a+b)
  10. 小白的Python之路 day1 用户输入
  11. centos7.2 配置内网ntp服务器进行时间同步
  12. js数组去除重复
  13. webpack使用三
  14. div中 li宽度不固定 ie6和ie7不兼容不自动换行
  15. 【CF744D】Hongcow Draws a Circle 二分+几何
  16. jquery如何获取第一个或最后一个子元素
  17. thinkjs项目中使用mongoose需要注意的地方
  18. java面试题(开发框架)
  19. SqlServer——字符串处理函数
  20. spring源码学习之:springAOP实现底层原理

热门文章

  1. Android——Runtime类中的freeMemory,totalMemory,maxMemory等几个方法
  2. Jsp servlet 值传递。。
  3. HTTP Status 500 - javax.servlet.ServletException
  4. ASP.NET验证控件二
  5. ADO.NET中的DataSet和DataAdapter
  6. POJ C++程序设计 编程题#1 编程作业—继承与派生
  7. Java 中的构造方法
  8. 一款jQuery特效编写的大度宽屏焦点图切换特效
  9. wordpress学习-themes-001
  10. “Unable to resolve target &#39;android-9&#39;”的问题