1.首先看了大佬的博客,发现longlong型数据开根约七次后会变成1,因此可以在查询函数中剪枝,一旦当前区域全都是1时,可以不必再往下更新。
2.这道题目的教训:输出格式:对于样例之间空行有没有要求?Case?等...
3.这道题有一个隐含的重要条件没有给出,需要自己判定:就是X和Y的大小关系(这给我们以后做题也有了一些提示)。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
const int maxn=100000+10;
int n,m,L,R,flag;
long long tree[maxn<<4];
void pushup(int rt)
{
tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build_tree(int l,int r,int rt)
{
if(l==r)
{
scanf("%lld",&tree[rt]);
return;
}
int m=(l+r)>>1;
build_tree(l,m,rt<<1);
build_tree(m+1,r,rt<<1|1);
pushup(rt);
}
void update(int l,int r,int rt)
{
if(l==r)
{
tree[rt]=sqrt(tree[rt]);
return;
}
if(L<=l&&r<=R&&tree[rt]==(r-l+1))
return;
int m=(l+r)>>1;
if(L&l