【杭电oj】1196 - Lowest Bit(位运算)
来源:互联网 发布:ubuntu使用yum gcc 编辑:程序博客网 时间:2024/04/28 06:26
Lowest Bit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10324 Accepted Submission(s): 7564
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.
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 <= 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 A in the input, output a line containing only its lowest bit.
Sample Input
26880
Sample Output
28
Author
SHI, Xiaohan
Source
Zhejiang University Local Contest 2005
简单位运算的题。
代码如下:
#include <stdio.h>int main(){int ans;int n;while (~scanf ("%d",&n) && n){ans=1;while (!(n&1))//n的二进制末尾是1时结束循环 {ans*=2;n>>=1;}printf ("%d\n",ans);}return 0;}
0 0
- 【杭电oj】1196 - Lowest Bit(位运算)
- 杭电oj 题目1196 Lowest Bit
- 杭电OJ——1196 Lowest Bit(水题)
- 杭电 1196 Lowest Bit (逻辑与的运算)
- Lowest Bit,杭电1196
- hdu 1196 Lowest Bit【位运算】
- Lowest Bit(hdu1196,位运算)
- 杭电acm水题 1196 Lowest Bit
- 杭电 HDU 1196 Lowest Bit
- hdu-oj 1196 Lowest Bit
- hdu 1196(Lowest Bit)
- zju2417最低位Lowest Bit
- HDOJ 1196:Lowest Bit——用位操作求解
- 【杭电oj】2028-Lowest Common Multiple Plus(最小公倍数)(水)
- HDU 1196 Lowest Bit (水)
- hdu - 1196 - Lowest Bit(bitset)
- HDU 1196 Lowest Bit (数位)
- HDU 1196 Lowest Bit(水~)
- hdoj2036改革春风吹满地
- SpringMVC和Struts2比较
- poj2240
- iOS容易造成循环引用的三种场景,就在你我身边!
- 分类算法之朴素贝叶斯分类(Naive Bayesian classification)
- 【杭电oj】1196 - Lowest Bit(位运算)
- 无需刷机!Semi-Restore恢复原始纯净越狱系统
- 【STL】STL容器之map
- react-native组件学习(二)
- Instrumentation简介
- 关于Inernet Explorer缓存服务器响应的问题,对Ajax的应用的影响
- Python机器学习库scikit-learn实践
- jquery动态添加tab内嵌ifream插件
- Controller注解形式做Spring MVC开发