hdu1196(Lowest Bit)
来源:互联网 发布:淘宝怎么取消实名认证 编辑:程序博客网 时间:2024/06/05 16:11
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#include<stdio.h>#include<math.h>int main(){ int a,b[1000],i,sum; while(scanf("%d",&a)==1&&a) { i=-1; while(a) { b[++i]=a%2; if(b[i]) break; a/=2; } sum=0; for(i=i;i>=0;i--) sum+=(int)(b[i]*pow(2.0,i*1.0)); printf("%d\n",sum); }}
- HDU1196:Lowest Bit
- hdu1196(Lowest Bit)
- HDU1196 Lowest Bit
- hdu1196 Lowest Bit
- hdu1196 Lowest Bit
- hdu1196 Lowest Bit
- HDU1196 ZOJ2417 Lowest Bit
- ZOJ2417&&HDU1196-Lowest Bit
- HDU1196 Lowest Bit
- hdu1196 Lowest Bit
- Lowest Bit(hdu1196,位运算)
- Lowest Bit
- Lowest Bit
- 【Lowest Bit】
- Lowest Bit
- Lowest Bit
- Lowest Bit
- Lowest Bit
- 浏览器的工作原理:新式网络浏览器幕后揭秘
- 第十一堂课后作业
- C# Using MySQL
- 话说我打算一天学完object c语法,系列5--------来自书Objective-c程序设计
- 产生 X 个数 的排列
- hdu1196(Lowest Bit)
- 产品经理如何通过谈话沟通将需求分析趋于完善
- hdu Entropy 1053 哈夫曼树
- Selenite(月光石) --Rurutia
- 宇龙酷派202笔试题
- 对象库未注册这是个问题
- 网络技术独立的导火索-SDN和三个问题
- Application.EnableVisualStyles()的作用
- IIS写权限利用续以及写权限漏洞来由解释