题意:一道经典题,区间更新,区间查询。
解法:原来用的是线段树。后来学了树状数组的做法,感觉很神奇,贴上解法网址:http://www.docin.com/p-97026988.html?qq-pf-to=pcqq.c2c
代码:
/****************************************************
* author:xiefubao
*******************************************************/
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <string.h>
using namespace std;
typedef long long LL;
LL C[100100];
LL B[100100];
LL tool=0;
int lowbit(int x){return x&(-x);}
int N,Q;
void updateC(int x,LL t)
{
tool+=t;