区间更新:每个数开方
区间查询:区间和
操作次数太大,时间优化方法是,标记区间是否全为1,若是则停止更新操作
RE了好多次,坑爹的有 x > y 的数据
#include <stdio.h>
#include <math.h>
#include <algorithm>
#define L(i) (i) << 1
#define R(i) (i) << 1 | 1
#define N 100005
struct s_t
{
int l,r,isone;
__int64 sum;
int mid()
{
return (l + r) >> 1;
}
__int64 len()
{
return r - l + 1LL;
}
}st[N<<2];
__int64 a[N];
void build(int id,int l,int r)
{
st[id].l = l;
st[id].r = r;
if(l == r)
st[id].sum = a[l];
else
{
int mid = st[id].mid();
build(L(id),l,mid