题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1196

大水题   lowbit   的应用    (可以取出一个数二进制中的最后一个1。树状数组常用,Lowbit(x)=x&-x。 )

代码:

 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <ctype.h>
#include <iomanip>
#include <queue>
#include <stdlib.h>
using namespace std; int s[];
int t,n,m,p,i,j; int lowbit(int x)
{
return x&(-x);
} void add(int x, int d){
while (x <= n){
s[x] += d;
x += lowbit(x);
}
} int sum(int x){
int ans = ;
while (x > ){
ans += s[x];
x -= lowbit(x);
}
return ans;
} int main()
{
int A;
while(~scanf("%d",&A)){
if(A==)
break;
int d=lowbit(A);
printf("%d\n",d);
}
}

hdu Lowest Bit的更多相关文章

  1. hdu 1196 Lowest Bit

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1196 Lowest Bit Description Given an positive integer ...

  2. hdu 1098 Lowest Bit 解题报告

    题目链接:http://code.hdu.edu.cn/game/entry/problem/show.php?chapterid=1&sectionid=2&problemid=22 ...

  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. HDU 2028 Lowest Common Multiple Plus

    http://acm.hdu.edu.cn/showproblem.php?pid=2028 Problem Description 求n个数的最小公倍数.   Input 输入包含多个测试实例,每个 ...

  5. 【HDU 2028】Lowest Common Multiple Plus

    Problem Description 求n个数的最小公倍数. Input 输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数. Output 为每组测试数据输出它们的最小公倍数 ...

  6. HDU 2860 并查集

    http://acm.hdu.edu.cn/showproblem.php?pid=2860 n个旅,k个兵,m条指令 AP 让战斗力为x的加入y旅 MG x旅y旅合并为x旅 GT 报告x旅的战斗力 ...

  7. hdu 1908 Double Queue

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1908 Double Queue Description The new founded Balkan ...

  8. hdu 4000 Fruit Ninja 树状数组

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4000 Recently, dobby is addicted in the Fruit Ninja. ...

  9. hdu 5268 ZYB loves Score 水题

    ZYB loves Score Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...

随机推荐

  1. 经excel要将数据库(ORACLE)要插入数据

    大家都知道PL/SQL可以excel数据复制.我们也可以通过相同excel将数据插入到数据库. 下面我们就来简单的样品,并与主题演示 首先,我们创建了一个表test CREATE TABLE test ...

  2. SRS微信号和QQ组

    联系方式:https://github.com/winlinvip/simple-rtmp-server/wiki/v1_CN_Contact $(function () { $('pre.prett ...

  3. HDU 1232:流问题(并检查集合)

    pid=1232">畅通project Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  4. webBrower控件实现winform和webpage交互

    添加WebBrowser控件 private WebBrowser webBrowser1; 引用页面的document对象 HtmlDocument doc = webBrowser1.Docume ...

  5. HDU 4067 Random Maze

    意甲冠军: 一个"随机图"它被定义为具有以下性质如: 一个入口和一个出口 有向图 对于入口  出度比入度大1 对于出口  入度比出度大1 对于其它点  入度等于出度 现给出一幅有向 ...

  6. Block学习一门:基本使用,使用block包NSURLRequest异步请求

    首先,看一下下面的代码: void (^myFirstBlock)(int theOne,int theTwo) = ^(int theOne,int theTwo){ NSLog(@"== ...

  7. UVA 1291 Dance Dance Revolution(DP)

    意甲冠军:跳舞机有一个上5积分,分别central, top, bottom, left, right分,区区足站立还是需要1点物理,从一个单纯的脚central点上须要2点体力,从一个点上移动到相邻 ...

  8. ios至于理解锚

    锚点ios出现在少数地方,多数用在动画. 今天看了一部电影,以上所有关于锚,两年前锚这个概念看cocos2d当被接触的基本概念,当时我没怎么看,今天看了,刚刚好学习. 阅读blog,它是关于锚,像: ...

  9. newlisp 接受jenkins带空格的参数

    jenkins有一个参数text种类,它能够以文本的段落拷贝作为参数 newlispThe program receives parameters are separated by spaces, 更 ...

  10. 如何嗅闻交换网络和ARP骗子-ARP解释的原则

    在嗅探以太网(一般指嗅探器可以对流经的网络数据包窃听)(sniff)不为网络安全是好事,虽然网络管理员能够跟踪数据包,发现 互联网问题,但前提是,如果破坏者使用.在整个网络带来了严重的安全威胁. 至于 ...