D. The Child and Sequence
time limit per test

4 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite sequence of Picks.

Fortunately, Picks remembers how to repair the sequence. Initially he should create an integer array a[1], a[2], ..., a[n]. Then he should perform a sequence of m operations. An operation can be one of the following:

  1. Print operation l, r. Picks should write down the value of .
  2. Modulo operation l, r, x. Picks should perform assignment a[i] = a[imod x for each i (l ≤ i ≤ r).
  3. Set operation k, x. Picks should set the value of a[k] to x (in other words perform an assignment a[k] = x).

Can you help Picks to perform the whole sequence of operations?

Input

The first line of input contains two integer: n, m (1 ≤ n, m ≤ 105). The second line contains n integers, separated by space:a[1], a[2], ..., a[n] (1 ≤ a[i] ≤ 109) — initial value of array elements.

Each of the next m lines begins with a number type .

  • If type = 1, there will be two integers more in the line: l, r (1 ≤ l ≤ r ≤ n), which correspond the operation 1.
  • If type = 2, there will be three integers more in the line: l, r, x (1 ≤ l ≤ r ≤ n; 1 ≤ x ≤ 109), which correspond the operation 2.
  • If type = 3, there will be two integers more in the line: k, x (1 ≤ k ≤ n; 1 ≤ x ≤ 109), which correspond the operation 3.
Output

For each operation 1, please print a line containing the answer. Notice that the answer may exceed the 32-bit integer.

这题关键是证明啊。   好线段树。

详细证明见:http://codeforces.com/blog/entry/12513

#include <bits/stdc++.h>
;
typedef ],Max[MAX<<];
]+sum[o<<|];
    Max[o]=max(Max[o<<],Max[o<<|]);
}
;
    build(L,mid,o<<);
    build(mid+,R,o<<|);
    push_up(o);
}
;
    ,ls,rs,mod);
    ,R,o<<|,ls,rs,mod);
    push_up(o);
}
;
    ,k,x);
    ,R,o<<|,k,x);
    push_up(o);
}
LL Query(;
    ;
    ,ls,rs);
    ,R,o<<|,ls,rs);
    ) {
        build(,n,);
        ;i<m;i++) {
            scanf() {
                scanf(,n,,l,r));
            }
            ) {
                scanf(,n,,l,r,x) ;
            }
            ,n,,k,x);
            }
        }
    }
    ;
}

最新文章

  1. 解决NetBeans编辑器中文乱码问题
  2. AOP常用术语
  3. mongodb,redis,hbase 三者都是nosql数据库,他们的最大区别和不同定位是什么?
  4. 【BZOJ】【1770】【Usaco2009 Nov】lights 灯
  5. mysql 只给更新表的某个字段的授权
  6. 打印NxN的矩阵
  7. C语言库函数大全及应用实例三
  8. ARC属性中还能使用assign,copy,retain这些关键字吗
  9. 纯CSS图片缩放后显示详细信息
  10. spring基本知识
  11. 面向对象编程思想(OOP)
  12. amazeUI的confirm控件记录缓存问题的解决办法
  13. 解决XP系统任务管理器显示不全
  14. Python+Selenium学习--下载文件
  15. C#基础知识回顾-- 属性与字段
  16. Android之AppWidget
  17. linux -- 管道“|”
  18. Qt的窗口的最大化。
  19. Java虚拟机6:垃圾收集(GC)-1(内存溢出和内存泄漏的区别)
  20. QMetaEnum利用Qt元数据实现枚举(enum)类型值及字符串转换

热门文章

  1. bzoj 1029: [JSOI2007]建筑抢修【贪心+堆】
  2. [转]MVC之 自定义过滤器(Filter)
  3. 数据库恢复挂起解决办法【MSSQL】
  4. 用Martini、websocket实现单机版聊天室
  5. ajax怎么理解?
  6. FCC 基础JavaScript 练习6
  7. BPI-M1P(全志A20)刷Android启动卡之后启动的过程
  8. C++(变量类型-深入)
  9. python学习笔记- 补遗
  10. 国外一些好用的UX/UI设计工具和资源介绍