4373

思路:

  判断一个数列是否是等差数列:

    1,最大值减去最小值==(区间个数-1)*k;

    2,gcd==k;

    3,不能有重复(不会这判断这一条,但是数据水就过了);

来,上代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define maxn 300005 struct TreeNodeType {
int l, r, max, min, gcd, mid;
};
struct TreeNodeType tree[maxn << ]; int n, m, ai[maxn], ty; inline void in(int &now)
{
char Cget = getchar(); now = ;
while (Cget > '' || Cget < '') Cget = getchar();
while (Cget >= ''&&Cget <= '')
{
now = now * + Cget - '';
Cget = getchar();
}
} int gcd(int a, int b)
{
int tmp;
while(b!=) tmp=b,b=a%b,a=tmp;
return a;
} void tree_build(int now, int l, int r)
{
tree[now].l = l, tree[now].r = r;
if (l == r)
{
tree[now].gcd = ai[l] - ai[l - ];
tree[now].min = ai[l], tree[now].max = ai[l];
return;
}
tree[now].mid = l + r >> ;
tree_build(now << , l, tree[now].mid);
tree_build(now << | , tree[now].mid + , r);
tree[now].gcd = gcd(tree[now << ].gcd, tree[now << | ].gcd);
tree[now].max = max(tree[now << ].max, tree[now << | ].max);
tree[now].min = min(tree[now << ].min, tree[now << | ].min);
} void pre()
{
in(n), in(m);
for (int i = ; i <= n; i++) in(ai[i]);
tree_build(, , n);
} int tree_do(int now, int l, int r)
{
if (tree[now].l == l&&tree[now].r == r)
{
if (ty == ) return tree[now].max;
if (ty == ) return tree[now].min;
if (ty == ) return tree[now].gcd;
tree[now].gcd = ai[l] - ai[l - ];
tree[now].max = ai[l], tree[now].min = ai[l];
return ;
}
int res=;
if (l > tree[now].mid) res = tree_do(now << | , l, r);
else if (r <= tree[now].mid) res = tree_do(now << , l, r);
else
{
res = tree_do(now << , l, tree[now].mid);
if (ty == ) res = max(res, tree_do(now << | , tree[now].mid + , r));
if (ty == ) res = min(res, tree_do(now << | , tree[now].mid + , r));
if (ty == ) res = gcd(res, tree_do(now << | , tree[now].mid + , r));
}
if (ty == )
{
tree[now].gcd = gcd(tree[now << ].gcd, tree[now << | ].gcd);
tree[now].max = max(tree[now << ].max, tree[now << | ].max);
tree[now].min = min(tree[now << ].min, tree[now << | ].min);
}
return res;
} void solve()
{
int op, l, r, x, y, last = ;
for (int t = ; t <= m; t++)
{
in(op);
if (op == )
{
in(x), in(y);
x^=last,y^=last,ty=,ai[x]=y;
tree_do(,x,x);
if(x!=n) tree_do(,x+,x+);
}
else
{
in(l),in(r),in(x);
l^=last,r^=last,x^=last;
if(l==r)
{
last++;
printf("Yes\n");
continue;
}
int ma,mi,gcdd;
ty=,ma=tree_do(,l,r);
ty=,mi=tree_do(,l,r);
ty=,gcdd=tree_do(,l+,r);
if((ma-mi)==x*(r-l)&&abs(gcdd)==x) printf("Yes\n"),last++;
else printf("No\n");
}
}
} int main()
{
pre();
solve();
return ;
}

最新文章

  1. C# DataGridView使用记录分享
  2. EntityFramwork入门
  3. java工程包的命名(-dev.jar,-javadoc.jar,jar)
  4. C#操作Word (2)-- 打开&amp;关闭Word文档
  5. Visual Studio 2013密钥
  6. 五、python使用模块
  7. 接口(工厂模式&amp;代理模式)
  8. phonegap环境配置与基本操作
  9. a 标签的四个伪类
  10. 一个action读取另一个action里的session
  11. Call to localhost/127.0.0.1:9000 failed on connection exception:java.net.ConnectException的解决方案
  12. 基础必备Linux操作
  13. html-form
  14. &lt;jsp:param&gt;标签给属性赋值时的一个坑
  15. 蓝桥杯 每周一练 第一周(3n+1问题)
  16. Linux内核分析作业 NO.6
  17. (5)MySQL的查询:模糊查询(通配符查询like)、限制符查询(limit)、排序查询(order by)、分组查询(group by)、(子查询)
  18. day69
  19. JFreeChart 之折线图
  20. iOS:App 内部更改使用语言/ 重定义系统的宏

热门文章

  1. QA 、 QC &amp; QM软件测试入门专业名词解释 -- 灌水走起
  2. matlab使用摄像头人脸识别
  3. java的四种内部类(转)
  4. Spring 笔记(四)AOP
  5. Codeforces Round #329(Div2)
  6. CyclicBarrier和CountDownLatch的使用
  7. windows mobile 开发:让GPS一直在待机模式下也能运行
  8. 【bzoj4819】[Sdoi2017]新生舞会 分数规划+费用流
  9. Android应用如何打包?
  10. glibc内存泄露以及TCmalloc 简单分析