首页 > 编程语言 > 详细

【树状数组】POJ 2309 BST

时间:2015-08-19 20:46:34      阅读:126      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

/**
 *  @author      johnsondu
 *  @time        2015-8-19 16:37
 *  @type        Binary Index tree 
 *  @key         try to understand how to retrieve
 *              the last bit of a number which is 1.
 *  @url         http://poj.org/problem?id=2309
 */

int main()
{
    int tcase;
    int q;
    scanf("%d", &tcase);
    while(tcase --) {
        scanf("%d", &q);
        int lowbit = q & (-q);
        printf("%d %d\n", q-lowbit+1, q+lowbit-1);
    }

    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

【树状数组】POJ 2309 BST

原文:http://blog.csdn.net/zone_programming/article/details/47782887

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!