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 ...
随机推荐
- uva 10167 - Birthday Cake
题解:由于解太多,随机抓 A.B, 只要有符合就行了: (首先,Ax+By=0必须表示直线,即A.B不能同时为0:另外,要注意到直线不能过输入中的2N个点:检测点在直线的哪一侧,只需要简单的线性规划的 ...
- MongoDB资料--Java驱动, Hadoop驱动, Spark使用
MongoDB数据库备份: mongodump -h 192.168.1.160 -d MapLoc -o /usr/local/myjar/mongo/MapLoc/数据库还原:mongoresto ...
- Selenium2Library关键字
对Selenium2Library关键字的整理和翻译.英文不好,仅供参考. 1.Add Cookie [ name | value | path=None | domain=None | secure ...
- cad 画 tp图
本文记录了cad 绘制 结构图 和触摸屏激光图. 1作为一个新手,我先要做的是适应操作界面. 页面:ctrl+鼠标滚轮 (类比,ps,ad等软件都是这样的.) 选取,划线,图层.等... 2画图... ...
- gets和从键盘输入换行符
i was wrong! 虽然setbuf可以让程序自己管理缓冲,但是像getchar,gets这些标准IO函数还是要通过隐藏的stdin进行操作,而stdin是啥呢?还是一个FILE*,而FILE* ...
- 十分钟让你的ASP.NET MVC网站变成PHP
昨天从网上看来的,某个人发的方法: 第一:修改一下路由: 把RouteConfig中的: routes.MapRoute( name: "Default", url: " ...
- Gradle Android客户端程序打包(基于gradle 2.10版本验证通过)
一.前言 目前正在准备从eclipse开发环境向AndroidStudio迁移,提前过去探探路,不出所料,原来gradle脚本果然报错,无法运行,想想索性把本地的gradle一起升级到最新版本,毕竟1 ...
- cf C. Levko and Array Recovery
http://codeforces.com/contest/361/problem/C 这道题倒着一次,然后正着一次,在正着的一次的时候判断合不合法就可以. #include <cstdio&g ...
- 这样就算会了PHP么?-9
PHP关于COOKIE的应用 <?php if (!isset($_COOKIE["visittime"])) { setcookie("visittime&quo ...
- 从客户端(txtNewsContent="<hr />")中检测到有潜在危险的 Request.Form 值。怎么办呀?
<system.web><httpRuntime requestValidationMode="2.0" executionTimeout="3600& ...