题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=1196

Lowest Bit

Description

Given an positive integer $A (1 \leq A \leq 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 \leq A \leq 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<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
using std::set;
using std::map;
using std::cin;
using std::cout;
using std::endl;
using std::find;
using std::sort;
using std::pair;
using std::vector;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define iter(c) decltype((c).begin())
#define cls(arr,val) memset(arr,val,sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
const int Max_N = ;
typedef unsigned long long ull;
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int n, ans;
while (~scanf("%d", &n) && n) {
ans = ;
while (true) {
if (n & ) break;
ans <<= ;
n >>= ;
}
printf("%d\n", ans);
}
return ;
}

hdu 1196 Lowest Bit的更多相关文章

  1. hdu 1098 Lowest Bit 解题报告

    题目链接:http://code.hdu.edu.cn/game/entry/problem/show.php?chapterid=1&sectionid=2&problemid=22 ...

  2. hdu 2028 Lowest Common Multiple Plus(最小公倍数)

    Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  3. HDOJ 1196 Lowest Bit(二进制相关的简单题)

    Problem Description Given an positive integer A (1 <= A <= 100), output the lowest bit of A. F ...

  4. hdu 1196

    Problem Description Given an positive integer A (1 <= A <= 100), output the lowest bit of A. F ...

  5. HDU 2028 Lowest Common Multiple Plus

    http://acm.hdu.edu.cn/showproblem.php?pid=2028 Problem Description 求n个数的最小公倍数.   Input 输入包含多个测试实例,每个 ...

  6. 【HDOJ】1196 Lowest Bit

    水题,原理是计算机组成原理中的负数的补码的求码.利用按位与可解. #include <iostream> using namespace std; int main() { int n; ...

  7. Problem : 1196 ( Lowest Bit )

    第一次一次通过,逻辑太简单... #include<iostream> using namespace std; void main() { int n; while(cin>> ...

  8. HDOJ 1196 Lowest Bit

    题目大意是给一个1-100的整数,要求首先转化成2进制,然后从最低位开始数起到不是0的位停止,输出这些位代表队额10进制数 #include <iostream> using namesp ...

  9. 最大公约数最小公倍数 (例:HDU2028 Lowest Common Multiple Plus)

    也称欧几里得算法 原理: gcd(a,b)=gcd(b,a mod b) 边界条件为 gcd(a,0)=a; 其中mod 为求余 故辗转相除法可简单的表示为: int gcd(int a, int b ...

随机推荐

  1. 默菲定律 [Murphy's Law]

    一.关于默菲定律(Murphy's Law)   “墨菲定律”.“帕金森定律”和“彼德原理”并称为二十世纪西方文化三大发现. “墨菲定律”的原话是这样说的:If there are two or mo ...

  2. OpenJudge 取数游戏

    描述 我们来玩一个游戏:自然数1到N,按顺序列成一排,你可以从中取走任意个数,但是相邻的两个不可以同时被取走.如果你能算出一共有多少种取法,那么你会被天神Lijiganjun奖励. 输入 仅包含一个数 ...

  3. python列表的常用操作方法

    主要介绍了Python中列表(List)的详解操作方法,包含创建.访问.更新.删除.其它操作等,需要的朋友可以参考下. 1.创建列表.只要把逗号分隔的不同的数据项使用方括号括起来即可 List = [ ...

  4. HTML中,按钮button与submit区别是什么?

    type=button 单纯是按钮功能:type=submit 是发送表单:既然是这样,那么能否全部用submit代替button? Sumit提交表单,Button需要绑定事件才可以用提交数据不可以 ...

  5. WP_图片管理机制/异步读取网络图片

    项目有这样的需求, 要求窗口加载一揽子图片,为了不让UI阻塞太久,采用异步读取后绑定显示的方案. 图片的下载应该采用并发的过程(等待网络响应会很耗时,一张一张的下载,等待时间太长) 图片的下载不能占用 ...

  6. poj3020

    define     n    the number of  ' * ' define     d    the number of couple of two points define     s ...

  7. 去HTML代码

    Code: public static string NoHTML(string Htmlstring) { //删除脚本 Htmlstring = Regex.Replace(Htmlstring, ...

  8. C#基础-ref、out

    1.默认情况下,C#假定所有的方法参数传递都是传值的. 如下面的方法: public static void Main(string[] args) { int val = 5; //调用AddVal ...

  9. 解决Android sdk更新不能下载或下载内容过慢

    Android Android SDK 配置步骤 启动 Android SDK Manager ,打开主界面,依次选择「Tools」.「Options...」,弹出『Android SDK Manag ...

  10. MySql安装方法和配置、解决中文乱码

    MySql Server安装步骤 1安装MySql Server 2 安装MySqlServer管理工具 解压中文语言包,将文件复制到安装目录下覆盖 文件覆盖后,打开软件设置语言为中文(CN) 3 M ...