题目连接

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. windows 10 笔记本关机不断电解决

    右键我的电脑-->管理-->设备管理器-->系统设备 找到Intel(R) Management Engine Interface  双击打开,禁用,确定,完事 原因,该驱动11.0 ...

  2. 实现web页面按比例缩放

    对于web的掌握限于可以看懂别人的代码,并在框架中作相应修改或增加. 今天把另一个项目中的网页源代码粘过来做一个页面,结果问题百出. 首先,同样的代码,放在自己的项目里,页面排版错乱,看了下,引用的w ...

  3. 火箭18号秀光膀为父母割草(FW)

    火箭18号秀光膀为父母割草 一夜致富不改本色 来源:新浪 2015年06月30日 分享到: 更多 收藏 分享 被浏览5次   <ignore_js_op id="r_article_i ...

  4. Android基础总结(12)——XML和JSON解析

    XML和JSON解析 在网络上传输数据时最常用的格式有两种:XML和JSON.本文主要就是学习如何对这两种常用的数据格式进行解析. 1.XML和JSON的定义 XML:扩展标记语言 (Extensib ...

  5. STM32F05 学习中............

    今天,拿到stm32f05的板子已经三个月了吧,但是没有真的研究过,真的对板子过意不去了...所以决定今天好好的对待我的板子.

  6. Aster及其它遥感数据下载地址

    免费下载TM,ETM的网址,速度还行,本人下载过, http://glcfapp.umiacs.umd.edu 还有一个是下载其他数据的,也可以去看看免费下载·遥感数据http://daac.gsfc ...

  7. ios开发之OC基础-类和对象

    本系列的文章主要来自于个人在学习前锋教育-欧阳坚老师的iOS开发教程之OC语言教学视频所做的笔记,边看视频,边记录课程知识点.建议大家先过一遍视频,在看视频的过程中记录知识点关键字,把把握重点,然后再 ...

  8. Linux之samba搭建

    参考资料: http://www.cnblogs.com/mchina/archive/2012/12/18/2816717.html

  9. leetcode 14

    14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array ...

  10. IIS URL重写找不到页面 (URLRewriter.dll伪静态)

    在网站上点右键 属性 进入主目录菜单 点击配置 找到.html扩展名 编辑 将 检查文件是否存在 的钩去掉! OK