hdu Lowest Bit
题目链接: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的更多相关文章
- hdu 1196 Lowest Bit
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1196 Lowest Bit Description Given an positive integer ...
- hdu 1098 Lowest Bit 解题报告
题目链接:http://code.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=2&problemid=22 ...
- hdu 2028 Lowest Common Multiple Plus(最小公倍数)
Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- HDU 2028 Lowest Common Multiple Plus
http://acm.hdu.edu.cn/showproblem.php?pid=2028 Problem Description 求n个数的最小公倍数. Input 输入包含多个测试实例,每个 ...
- 【HDU 2028】Lowest Common Multiple Plus
Problem Description 求n个数的最小公倍数. Input 输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数. Output 为每组测试数据输出它们的最小公倍数 ...
- HDU 2860 并查集
http://acm.hdu.edu.cn/showproblem.php?pid=2860 n个旅,k个兵,m条指令 AP 让战斗力为x的加入y旅 MG x旅y旅合并为x旅 GT 报告x旅的战斗力 ...
- hdu 1908 Double Queue
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1908 Double Queue Description The new founded Balkan ...
- hdu 4000 Fruit Ninja 树状数组
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4000 Recently, dobby is addicted in the Fruit Ninja. ...
- hdu 5268 ZYB loves Score 水题
ZYB loves Score Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
随机推荐
- CentOS7卸载KDE桌面(转)
最初安装centos时选择了安装KDE桌面,打开很卡,没有用到,想卸载,可是试了网上的方法什么yum groupremove kde-desktop 都不奏效,于是只能自己找出KDE的包,然后yum卸 ...
- swing中几种layout示例(转)
import java.awt.BorderLayout;import java.awt.FlowLayout;import java.awt.GridLayout;import java.awt.e ...
- 在JBuilder8在使用ANT
在JBuilder8中使用ANT 作者:翁驰原 在JBuilder8中.Ap ...
- Codeforces 549H. Degenerate Matrix 二分
二分绝对值,推断是否存在对应的矩阵 H. Degenerate Matrix time limit per test 1 second memory limit per test 256 megaby ...
- 你听说过XML吗?
我们每天都会见到各种各样的书,今天我们就来谈一谈有关书籍带给我们学习的启发. 正如上图所看到的,不同的书籍有不同的外观,比如教科书.儿童图书等:而且书也不是随便能够出版的,要有自己文档结构,语义规则. ...
- hdu 1150 Machine Schedule(最小顶点覆盖)
pid=1150">Machine Schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/327 ...
- C++基于该模型模板包括节目外实例
一个."经典模式"失败 我们学过C++的人都知道.在C++中组织代码的经典模型是:将函数或类的声明和定义部分分开在不同的文件之中 , 即一般将声明放在一个.h的头文件里而定义在 ...
- MongoDB日常保养
它引入了程序来进行维护管理工具 MongoDB的日常维护包含使用配置文件,设置訪问控制.Shell交互,系统监控和管理,数据库日常备份和恢复 启动和停止MongoDB 启动后能够通过数据库的IP加po ...
- CGI原理解析系列之中的一个----CGI怎样获取WEBserver数据
//gcc get_post.c -o get_post.ums; #include <stdio.h> #include <stdlib.h> #include <un ...
- Android虚拟机器学习总结Dalvik虚拟机创建进程和线程分析
Dalvik调用一个成员函数时,虚拟机,假设发现,该成员函数是一个JNI办法,然后,它会直接跳转到其地址来运行.也就是说.JNI方法是直接在本地操作系统上运行的.而不是由Dalvik虚拟机解释器运行. ...