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. centos搭建zabbix

    安装一些依赖包,不同情况缺的包不同 yum install mysql-devel curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd ph ...

  2. [原]C++程序示例:涉及到抽象类、继承…

    C++复习题. 有助于理解: .h与.cpp分离 基类.派生类.抽象类 多态.纯虚函数 对象指针.引用 派生类使用基类的构造函数 ... =============================== ...

  3. 【0】python核心编程,第二章

    1.print语句也支持将输入重定向到文件,示例: logfile = open('/tmp/mylog.txt', 'a') print >> logfile, 'Fatal error ...

  4. Stars(BIT树状数组)

    Stars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  5. Windows中安装Emacs

    首先从http://gnu.org/software/emacs中下载window下的压缩包,然后解压..运行ROOT/bin/addpm.exe进行安装. 将鼠标右键添加Emacs编辑: 1. 打开 ...

  6. php设置和获取变量类型

    1. 获取变量类型 gettype($a); 2. 设置变量类型 settype($a,'int'); 3. 测试函数 is_array();是否数组 is_string();是否字符串 is_obj ...

  7. Qt中调用PolarSSL库(一)

    最近一直在学习SSL相关的知识,也是先了解理论相关的知识,主要是SSL相关的基本概念和连接建立过程,主要是基于PolarSSL开源库进行学习.学习完了之后就希望能给有所运用,就想用Qt写一个简单的程序 ...

  8. setTimeout()使用

    Basic setTimeout() Example setTimeout(function() {       // Do something after 5 seconds }, ); Tip:  ...

  9. Linux下alias命令

    功能说明:设置指令的别名.语 法:alias[别名]=[指令名称]参 数 :若不加任何参数,则列出目前所有的别名设置.举    例 :ermao@lost-desktop:~$ alias       ...

  10. hdu 4751 Divide Groups(dfs染色 或 2-sat)

    Problem Description   This year is the 60th anniversary of NJUST, and to make the celebration more c ...