博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lowest Bit
阅读量:4473 次
发布时间:2019-06-08

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

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.

 

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

26

88

0

 

Sample Output

2

8

 

1 #include 
2 #include
3 4 5 int main(){ 6 int A; 7 int timer; 8 9 while(1){10 timer=0;11 scanf("%d",&A);12 13 if(A==0)14 break;15 16 while(1){17 if(A%2==0){18 timer++;19 A/=2;20 }21 22 else{23 printf("%.0lf\n",pow(2.0,timer));24 break;25 }26 27 } 28 }29 30 return 0;31 }

 

转载于:https://www.cnblogs.com/zqxLonely/p/4054475.html

你可能感兴趣的文章
Git
查看>>
ImageSwitcher 右向左滑动的实现方式
查看>>
数学之美读书笔记一信息的度量和作用
查看>>
《荣枯鉴》示伪卷八
查看>>
NLP 第10章 基于深度学习的NLP 算法
查看>>
win7下出现'telnet' 不是内部或外部命令,也不是可运行的程序或批处理文件的解决方法...
查看>>
Maven 依赖范围(转)
查看>>
Google Chrome中的高性能网络(转)
查看>>
[置顶] 数据结构之 二叉树的构造与遍历(先序,中序,后序,层次)
查看>>
Tomcat在处理GET和POST请求时产生的乱码问题
查看>>
XSS 攻击原理及防护
查看>>
操作符重载
查看>>
Docker 安装及问题处理
查看>>
JavaScript中的call 和apply的用途以及区别
查看>>
HashMap完全解读
查看>>
匿名内部类
查看>>
man命令重定向后有^H乱码问题
查看>>
自定义popupwindow(解决位置控制困惑)
查看>>
BZOJ4071: [APIO2015]八邻旁之桥
查看>>
Redis的六种特性 场景
查看>>