東京海上日動プログラミングコンテスト2022(AtCoder Beginner Contest 256)
翻译中…
Problem Statement
翻译中…
You are given $N$, $Q$, and $A=(a_1,\ldots,a_N)$.
Process $Q$ queries described below. Each query is of one of the following three kinds:
翻译中…
1 L R x: for$i=L,L+1,\dots,R$, update the value of$a_i$to$\displaystyle \left\lfloor \frac{a_i}{x} \right\rfloor$.2 L R y: for$i=L,L+1,\dots,R$, update the value of$a_i$to$y$.3 L R: print$\displaystyle\sum_{i=L}^R a_i$.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 5 \times 10^5$$1 \leq Q \leq 10^5$$1 \leq L \leq R \leq N$$1 \leq a_i \leq 10^5$$2 \leq x \leq 10^5$$1 \leq y \leq 10^5$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format, where $\text{query}_i$ denotes the $i$-th query to be processed:
翻译中…
N Q
a_1 a_2 \dots a_N
\text{query}_1
\text{query}_2
\vdots
\text{query}_Q
翻译中…
Each query is given in one of the following three formats:
翻译中…
1 L R x
翻译中…
2 L R y
翻译中…
3 L R
翻译中…
Output
翻译中…
Print the answer to the queries as specified in the Problem Statement, with newlines in between.
翻译中…
样例
Input #1
3 5
2 5 6
3 1 3
1 2 3 2
3 1 2
2 1 2 3
3 1 3
Output #1
13
4
9
Initially, $A = (2, 5, 6)$. Thus, the answer to the $1$-st query is $a_1 + a_2 + a_3 = 2 + 5 + 6 = 13$.
When the $2$-nd query has been processed, $A = (2, 2, 3)$. Thus, the answer to the $3$-rd query is $a_1 + a_2 = 2 + 2 = 4$.
When the $4$-th query has been processed, $A = (3, 3, 3)$. Thus, the answer to the $5$-th query is $a_1 + a_2 + a_3 = 3 + 3 + 3 = 9$.
Input #2
6 11
10 3 5 20 6 7
3 1 6
1 2 4 3
3 1 3
2 1 4 10
3 3 6
1 3 6 2
2 1 4 5
3 1 6
2 1 3 100
1 2 5 6
3 1 4
Output #2
51
12
33
26
132
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。