线段树笔记之建树

#include<bits/stdc++.h> 
using namespace std;
struct  node1{int l,r,value;};
node1 node[100010];	----------> node是村树的数组
int a[100010];	----------> a是输入数组
inline void mt(int p,int l,int r)
{
    int mid=(l+r)>>1;
    node[p].l=l;
    node[p].r=r;
    if(l==r)
    {
        node[p].value=a[l];
        return;
    }
    mt(p<<1,l,mid);
    mt(p<<1|1,mid+1,r);	----------> |1 相当于+1
    node[p].value=node[p<<1].value+node[p<<1|1].value;
}
int main()
{
	
	return 0;
}

posted @ 2024-01-25 10:47  Arthur_Douglas  阅读(7)  评论(0编辑  收藏  举报