线段树笔记之建树
#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;
}
本文来自博客园,作者:Arthur_Douglas,转载请注明原文链接:https://www.cnblogs.com/wenzhihao2023/p/17986672