poj 2309(树状数组lowbit)
2014-06-28 11:21
281 查看
题意是给你一个满二叉树,给一个数字,求以这个数为根的树中最大值和最小值。
理解树状数组中的lowbit的用法。
目前的个人理解就是 lowbit 求出来的是这个根的管辖区域。
代码:
理解树状数组中的lowbit的用法。
目前的个人理解就是 lowbit 求出来的是这个根的管辖区域。
代码:
#include <stdio.h> int lowbit(int n) { return n & (-n); } int main() { int ncase; scanf("%d", &ncase); while (ncase--) { int k; scanf("%d", &k); printf("%d %d\n", k - lowbit(k) + 1, k + lowbit(k) - 1); } return 0; }
相关文章推荐
- POJ 2309 BST (树状数组)
- poj 2309 BST 使用树阵lowbit
- poj 2309 BST(lowbit)
- POJ 2309:BST lowbit
- BIT (树状数组) ——Poj 3067 Japan
- POJ 2309 BST 树状数组基本操作
- POJ 2309:BST lowbit
- POJ 2309 BST(树状数组)
- POJ1195 Mobile phones —— 二维树状数组(二维BIT)
- 【树状数组】POJ 2309 BST
- POJ 2309 BST 树状数组基本操作
- POJ 2309树状数组的简单变型
- POJ 3067 Japan【树状数组】
- poj 3321 Apple Tree( 树状数组 )
- poj 2352(树状数组)
- poj 2352 树状数组
- poj 2481(树状数组)
- 【原】 POJ 2352 Stars 树状数组 解题报告
- Poj 1195 二维树状数组
- POJ 3321 AppleTree (树状数组)