博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
最低位 【杭电-HDOJ-1196】 附题
阅读量:7082 次
发布时间:2019-06-28

本文共 952 字,大约阅读时间需要 3 分钟。

/*

Lowest Bit
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7775    Accepted Submission(s): 5714

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
#include
int main(){ int n; while(~scanf("%d",&n),n) { //printf("%d\n",n&(-n)); printf("%d\n",n^(n&(n-1))); } return 0;}

转载地址:http://cilml.baihongyu.com/

你可能感兴趣的文章
js 中的 Data() 对象
查看>>
发送字符与字符串v
查看>>
在局域网部署git
查看>>
百度外卖面试记录
查看>>
IOS开发网络第一天之02NSThread的基本使用
查看>>
静态页面时用js获取后台信息
查看>>
解决linux环境下,atom编辑器不支持中文的问题
查看>>
pyspider爬虫学习-文档翻译-Frequently-Asked-Questions.md
查看>>
小众时代的定制服务器来临了么
查看>>
IPv4/IPv6 socket
查看>>
#pragma once与#ifndef #define ...#endif的区别
查看>>
模拟复数及其运算
查看>>
IOS上路_01-Win7+VMWare9+MacOSX10.8+XCode4.6.3
查看>>
给Visual Studio 2010添加Windows Phone 7模板
查看>>
一次 web 工程性能测试
查看>>
wordpress 伪静态nginx设置
查看>>
今天写sql无意中发现了一个深坑
查看>>
记一次dell R720服务器ESXI5.5系统宕机的奇葩经历
查看>>
CMD一键获取 所有连接过的WIFI密码
查看>>
RabbitMQ
查看>>