题目链接: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. C# List使用District去重复数据

    class ListDistinctDemo { static void Main(string[] args) { List<Person> personList = new List& ...

  2. NGUI判断是否点击到UI控件

    注意:UI应加上Box Collider 1.射线检测 UICamera发一条射线,射线碰到了东西就说明点击到了UI Ray ray=UICamera.mainCamera.ScreenPointTo ...

  3. SpringMVC+Mybatis(SMM)+mybatis-generate

    java搭建 SpringMVC+Mybatis(SMM)+mybatis-generate 搭建SSM系统,首先要了解整个过程: 1.创建spring-mvc项目 2.在maven中添加要引用的ja ...

  4. JS弄ASP.NET(C#)在页GridView信息选择行

    做web发展还是新手我,为了之前获得Gridview中间值,它是通过服务器端控件通过第一Gridview将数据保存到服务器,当一个服务器,然后绑定的隐藏字段,在通过的js阅读隐藏字段值,如今,这种方法 ...

  5. BZOJ 2038: [2009国家集训队]小Z的袜子(hose) 分块

    分块大法好 2038: [2009国家集训队]小Z的袜子(hose) Time Limit: 20 Sec  Memory Limit: 259 MB Submit: 2938  Solved: 13 ...

  6. docker-gitlab(转)

    Issues Docker is a relatively new project and is active being developed and tested by a thriving com ...

  7. 【原创】构建高性能ASP.NET站点 第五章—性能调优综述(后篇)

    原文:[原创]构建高性能ASP.NET站点 第五章-性能调优综述(后篇) 构建高性能ASP.NET站点 第五章—性能调优综述(后篇) 前言:本篇主要讲述如何根据一些简单的工具和简单的现象来粗布的定位站 ...

  8. phpword这个问题的产生中国扭曲

    采用phpword经word模板生成word当文件,乱码的问题.矿php和所有的数据库使用urf8编码格公式.解决的办法是,到场/phpword/template.php档,守则   $replace ...

  9. Cocos2d-x 3.0final 终结者系列教程04-引擎架构分析

    从前,有一个跟我来Android学生,总是问我: 沉老师,为什么Android的形式被称为Activity,为什么要onCreate方法写setContentView(R.layout.main)? ...

  10. Android应用启动还有一个应用

    已知包名和应用入口Activity 包名:org.ww 应用入口:Activity:org.ww.TestActivity Intent intent = new Intent(); intent.s ...