#902. 区间修改,区间查询
区间修改,区间查询
Cannot parse: (0 , import_utils.normalizeSubtasks) is not a function or its return value is not iterable
Background
Special for beginners, ^_^
Description
这是一道模板题。
给定数列 a[1], a[2], , a[n],你需要依次进行 q 个操作,操作有两类:
1 l r x:给定 l,r,x,对于所有 ,将 a[i] 加上 x(换言之,将 a[l], a[l+1], , a[r] 分别加上 x);2 l r:给定 l,r,求 的值(换言之,求 a[l]+a[l+1]++a[r] 的值)。
Format
Input
第一行包含 2 个正整数 n,q,表示数列长度和询问个数。保证 。 第二行 n 个整数 ,表示初始数列。保证 。 接下来 q 行,每行一个操作,为以下两种之一:
1 l r x:对于所有 ,将 a[i] 加上 x;2 l r:输出 的值。
保证 。
Output
对于每个 2 l r 操作,输出一行,每行有一个整数,表示所求的结果。
Samples
5 10
2 6 6 1 1
2 1 4
1 2 5 10
2 1 3
2 2 3
1 2 2 8
1 2 3 7
1 4 4 10
2 1 2
1 4 5 6
2 3 4
15
34
32
33
50
Limitation
对于所有数据,$1\le n,q\le 10^6, |a[i]|\le 10^6, 1\le l\le r\le n, |x|\le 10^6$。
1s, 1024KiB for each test case.