博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lowest Bit(虽然很简单)
阅读量:4356 次
发布时间:2019-06-07

本文共 950 字,大约阅读时间需要 3 分钟。

Lowest Bit

Time Limit: 1000MS Memory limit: 65536K

题目描述

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.

输入

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.

输出

For each A in the input, output a line containing only its lowest bit.

示例输入

26880

示例输出

28

#include 
int main(){ int n; int sum; while(scanf("%d",&n), n != 0) { sum = 1; while( (n & 1) == 0)//这里(n&1)一定要括起来。。&优先级不够高啊。。费了很大劲才知道的。。好吧。我承认我很低级。。 { n /= 2; sum *= 2; } printf("%d\n",sum); } return 0;}

转载于:https://www.cnblogs.com/tanhehe/archive/2012/10/21/2883529.html

你可能感兴趣的文章
IOS学习笔记(二)UIDatePicker
查看>>
8款HTML5动画特效推荐源码
查看>>
网页加载时域名加载数量限制
查看>>
深入理解Java中的final关键字
查看>>
4412开发板搭建Uboot、Kernel和Android4.0的编译环境方法
查看>>
iTOP4418开发板7寸屏幕Android系统下横竖屏设置
查看>>
hibernate之HelloWorld
查看>>
CoreAPI_Update
查看>>
Uva 534 - Frogger (最小瓶颈路)
查看>>
51Nod 1183 - 编辑距离(DP)
查看>>
浅谈Tuple之C#4.0新特性那些事儿你还记得多少?
查看>>
仿制mac效果
查看>>
JAVA Atm测试实验心得
查看>>
通过fsharp 使用Enterprise Library Unity 2
查看>>
C# 多态
查看>>
[BZOJ1057][ZJOI2007]棋盘制作 单调栈
查看>>
[转载] Windows系统批处理延迟方法
查看>>
STM32_DAC之软件触发(Trigger)
查看>>
点击elementUI中的popover组件,让组件里的input二次获取焦点有效的两种情况
查看>>
简单注册匡
查看>>