hdu 1196
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 <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip> using namespace std;
int lowbit(int x)
{
return x&(-x);
}
int main()
{ int n;
while(cin>>n&&n)
{
cout<<lowbit(n)<<endl;
}
return 0;
}
hdu 1196的更多相关文章
- hdu 1196 Lowest Bit
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1196 Lowest Bit Description Given an positive integer ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
- hdu Lowest Bit
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1196 大水题 lowbit 的应用 (可以取出一个数二进制中的最后一个1.树状数组常用, ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- HDU 5687 Problem C(Trie+坑)
Problem C Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- HDU 2578 Dating with girls(1) [补7-26]
Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
随机推荐
- 内核参数优化之1 keepalive解析
以下信息纯属虚构,切勿相信! tcp/ip协议中有一个keep-alive机制,即检查空连接的时效性,当一个空连接持续一段时间后,就会发送一个keep-alive探测包,来探测客户端是否还存在. 如果 ...
- DataTables自定义筛选器
/* Custom filtering function which will search data in column four between two values */ $.fn.dataTa ...
- Android学习笔记--Handler用法总结
不错的例子:http://www.cnblogs.com/menlsh/archive/2013/06/07/3125341.html 转自:一叶知秋的博客 http://blog.sina.com. ...
- laravel实现第三方登录(qq登录)
首先composer安装依赖: composer require socialiteproviders/qq 注册服务提供者(同时注释掉原有的Socialite提供者): 'providers' =& ...
- AFNnetworking快速教程,官方入门教程译
AFNnetworking快速教程,官方入门教程译 分类: IOS2013-12-15 20:29 12489人阅读 评论(5) 收藏 举报 afnetworkingjsonios入门教程快速教程 A ...
- Chrome下的语音控制框架MyVoix.js使用篇(一)
日前因工作需求,着手研究了语音识别技术,发现github上有网友发布了一款叫做voix.js的javascript框架.在拜读voix.js的源码后发现了不少问题,于是自己写了一款语音识别框架MyVo ...
- $parse , $interpolate ,$complie , $destroy
$parse 是angular 提供的javascript解析器 . var getter = $parse(expression); var setter = getter.assign; cont ...
- HDU 4116 Fruit Ninja
http://acm.hdu.edu.cn/showproblem.php?pid=4116 题意:给N个圆,求一条直线最多能经过几个圆?(相切也算) 思路:枚举中心圆,将其他圆的切线按照极角排序,并 ...
- wpf只运行一个实例
原文:wpf只运行一个实例 在winform下,只运行一个实例只需这样就可以: 1. 首先要添加如下的namespace: using System.Threading; 2. 修改系统Main函数, ...
- Thunderbird Mail 支持 Microsoft Exchange
Thunderbird地址:https://www.mozilla.org/en-US/thunderbird/ 插件下载地址:https://addons.mozilla.org/zh-CN/thu ...