Lowest Bit

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
  把n化为二进制数,然后找出最低位,例如101000 最低位为1000 为8, 
 #include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int fen(int n)
{
int i,a;
for(i=;n!=;i++)
{
a=n%;
if(a!=)
{
return i;
}
else
n=n/;
}
}
int main()
{
int n,i;
while(cin>>n)
{
if(n==)
break;
else
cout<<pow(,fen(n))<<endl; }
}

Lowest Bit(hdoj1196)的更多相关文章

  1. Python成长之路第二篇(1)_数据类型内置函数用法

    数据类型内置函数用法int 关于内置方法是非常的多这里呢做了一下总结 (1)__abs__(...)返回x的绝对值 #返回x的绝对值!!!都是双下划线 x.__abs__() <==> a ...

  2. http服务详解(2)——httpd的配置文件常见设置

    HTTP服务器应用 http服务器程序 httpd apache nginx lighttpd 应用程序服务器 IIS .asp tomcat .jsp jetty 开源的servlet容器,基于Ja ...

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

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

  4. Leetcode之深度优先搜索(DFS)专题-1123. 最深叶节点的最近公共祖先(Lowest Common Ancestor of Deepest Leaves)

    Leetcode之深度优先搜索(DFS)专题-1123. 最深叶节点的最近公共祖先(Lowest Common Ancestor of Deepest Leaves) 深度优先搜索的解题详细介绍,点击 ...

  5. Python基础(二)

    本章内容: Python 运算符(算术运算.比较运算.赋值运算.逻辑运算.成员运算) 基本数据类型(数字.布尔值.字符串.列表.元组.字典.set集合) for 循环 enumrate range和x ...

  6. 《learning hard C#学习笔记》读书笔记(19)多线程

    19.1 多线程编程知识 19.1.1 进程与线程的概念 进程: 可以理解为一块包含某些资源的内存区域,操作系统通过进程方式把它工作划分为不同的单元. 一个应用程序可以对应多个进程. 线程: 线程是进 ...

  7. windows消息机制详解(转载)

    消息,就是指Windows发出的一个通知,告诉应用程序某个事情发生了.例如,单击鼠标.改变窗口尺寸.按下键盘上的一个键都会使Windows发送一个消息给应用程序.消息本身是作为一个记录传递给应用程序的 ...

  8. c#多线程介绍(上)

    转载原文:这里是链接内容 转载原文:这里写链接内容 转载原文:这里写链接内容 (重要事情说三遍) 引言 本文主要从线程的基础用法,CLR线程池当中工作者线程与I/O线程的开发,并行操作PLINQ等多个 ...

  9. [.net 面向对象程序设计进阶] (16) 多线程(Multithreading)(一) 利用多线程提高程序性能(上)

    [.net 面向对象程序设计进阶] (16) 多线程(Multithreading)(一) 利用多线程提高程序性能(上) 本节导读: 随着硬件和网络的高速发展,为多线程(Multithreading) ...

随机推荐

  1. php-app开发接口加密

    自己平时工作中用到的一套接口加密规则,记录下来以后用: /** 2 inc 3 解析接口 客户端接口传输规则: 1.用cmd参数(base64)来动态调用不同的接口,接口地址统一为 http://a. ...

  2. putty设置

    1- 输入要链接的主机地址 2- 设置connection-->SSH-->Tunnels 点击Add 3- 设置connection 修改为30 4- 点击open,出现ssh登陆,输入 ...

  3. Android基础学习之context

    Context既是环境变量,也是句柄(handler),也是上下文.类似用使用工具的工具,比如写字来说,笔是工具,Context可以看成是手,用来使用笔.context具有唯一性,具有很多种行为(定义 ...

  4. HDU 3501 Calculation 2(欧拉函数)

    Calculation 2 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

  5. 关于C语言静态链接的个人理解,欢迎指正

    摘要:本篇主要介绍在静态链接中多个文件合并.地址确定.符号解析和重定位相关问题,以GCC编译器为例.     首先,链接器链接多个文件时,采用何种方式合并为一个文件?方式一,按序叠加,即多个文件依次叠 ...

  6. SmartBusinessDevFramework架构设计-3:考虑开源?

    掖着藏着,终归不是好的办法.说的跟花一样,究竟里子是什么东西.一个好的被子,里料是羽绒还是棉花还是丝绵还是黑心棉?有时候,真的是看过之后,才能体验其中的奥秘. 这个架构的设计初衷,总体是为了方便.ne ...

  7. 在WPF中使用ArcGIS Engine

    原文 http://blog.csdn.net/zzahkj/article/details/9102621 1.首先,新建一个WPF项目,添加引用ESRI.ArcGIS.AxControls.ESR ...

  8. LeeCode-Happy Number

    Write an algorithm to determine if a number is "happy". A happy number is a number defined ...

  9. HDU1754(线段树)

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  10. 【LeetCode练习题】Maximum Depth of Binary Tree

    Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the n ...