hdu1196 Lowest Bit
来源:互联网 发布:python 画时间轴 分钟 编辑:程序博客网 时间:2024/05/22 02:23
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
C语言AC代码
#include<stdio.h>int main(){ int a,i,k,s,answer; while(scanf("%d",&a)&&a) { s=0; answer=1; while(a) { k=a%2; if(k==1) { for(i=0;i<s;i++) answer=answer*2; printf("%d\n",answer); a=0; } a=a/2; s++; } } return 0;}
阅读全文
0 0
- 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++笔记——C语言与C++的区别
- 创建一个数组, 实现函数init()初始化数组、 实现empty()清空数组、 实现reverse()函数完成数组元素的逆置。 要求:自己设计函数的参数,返回值。
- HttpClient测试接口Test
- 实验二 线性表综合实验——静态链表
- [蓝书/Ch5] Collectors Problem UVA
- hdu1196 Lowest Bit
- jQuery实现轮播效果及stop()和is(:animated)的用法区别
- oracle知识点总结
- udt通信java
- Java入门笔记第四课(类)
- tomcat-maven-plugin的使用
- 单词树(最优二叉树)
- 分层图的一些人生经验
- Coursera吴恩达《优化深度神经网络》课程笔记(1)-- 深度学习的实用层面