1. hotman78

    No comment

    hotman78
Changes in body
Source | HTML | Preview
@@ -1,39 +1,40 @@
#ごめんなさい
可換性を必要とします
#気持ち
-![IMG_20200221_171036.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/68551/b3ccac28-a758-3cb2-3e7b-f5de7ced9573.jpeg)
+![DSC_0011.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/68551/59235aeb-84eb-71bf-ff04-e6ba8ad52ddd.jpeg)
+
+
確かに上手く行きそう
#実装
非再帰です
```c++:segment.cpp
template<typename T>
struct segment{
vector<T> node;
int n;
segment(int n):n(n){node.assign(n*2+1,e);}
T get(auto l,auto r){
l+=n;r+=n;
T s=e;
while(l<r){
if(l&1)f(s,node[l++]);
if(r&1)f(s,node[--r]);
l/=2;r/=2;
}
return s;
}
void update(auto t,T x){
t+=n;
while(t)f(node[t],x),t/=2;
}
T e=0;
void f(T& s,const T& t){
s+=t;
}
};
```
#vertify
[Range Sum Query(AOJ)](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B)