hdu 1196 Lowest Bit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7731 Accepted Submission(s): 5677
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
#include<cstdio>
#include<cmath>
int main()
{
int m;
while(scanf("%d",&m),m)
{
int s,i,t=0,a[10010],j=0;
while(m)
{
a[j++]=m%2;
m/=2;
}
j--;
while(a[t]==0)
{
t++;
}
/*printf("%d\n",t);*/
s=pow(2,t);
printf("%d\n",s);
}
return 0;
}
hdu 1196 Lowest Bit
原创
©著作权归作者所有:来自51CTO博客作者wx5f8d5a7b525f9的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:特殊回文数
下一篇:hdu 1232 畅通工程
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
hdu 1196 Lowest bit (水题)
思路:搞过树状数组就知道这题是有多简单。详情请看树状数组详解
#include #define 树状数组 -
HDU 1196 Lowest Bit(二进制)
Lowest BitTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 655
HDU 1196 Lowest Bit 二进制 #include -
HDU1196_Lowest Bit【位运算】【水题】
题目大意:给你一个数A,求它的二进制表示中最右边的1表示的数比如:
java #include 位运算 -
HDU1169-Lowest Bit
Lowest BitTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7514 Accepted Submission(s): 5517Problem DescriptionGiven an positive integ
HDU-1169Lowest Bit C语言 ACM C++ OJ #include 字符串 Java -
HDU 2028 Lowest Common Multiple Plus(LCM)
Lowest Common Multiple PlusTime Limit: 2000/1000 MS (Java/Others) Me
HDU 2028 Lowest Common Multip LCM #include -
HDU - 4421 Bit Magic
题目大意:看图就知道题目大意了 解题思路:每一位分开进行计算判断#include <cs
i++ Stack #include