P13980 Introduction to Sequence Block Decomposition 5
Background
The constraints of the testdata in Luogu's "Introduction to Sequence Block Decomposition" series differ from those of the original problems.
Description
You are given a sequence $a_1 \ldots a_n$ of length $n$ and $n$ operations. The operations involve range square root and range sum.
Input Format
The first line contains one integer $n$.
The second line contains $n$ integers, where the $i$-th integer is $a_i$, separated by spaces.
Then $n$ lines follow, each containing a query. Each line contains three integers $\mathrm{opt}, l, r$, separated by spaces.
If $\mathrm{opt} = 0$, it means that every number in $[l, r]$ is replaced by its square root. For each $a_i$ in the range $(l \le i \le r)$, $a_i \leftarrow \left\lfloor \sqrt{a_i}\right\rfloor$.
If $\mathrm{opt} = 1$, it means that you should query the sum of all numbers in $[l, r]$.
Output Format
For each query, output one integer on a single line giving the answer.
Explanation/Hint
### Subtasks
Subtask 1 (40 points): $1 \leq n \leq 50000$, $0 \leq a_i, \mathrm{ans} \leq 2^{31}-1$.
Subtask 2 (60 points): $1 \leq n \leq 300000$, $0 \leq a_i \leq 2^{31}-1$, $0 \leq \mathrm{ans} \leq 2^{63}-1$.
For all testdata, $1 \leq n \leq 300000$ and $0 \leq a_i \leq 2^{31}-1$, $0 \leq \mathrm{ans} \leq 2^{63}-1$. $1 \leq l \leq r \leq n$. $\mathrm{opt} \in \{0,1\}$, $1 \leq l \leq r \leq n$. After each operation every $a_i$ satisfies $0 \leq a_i \leq 2^{31}-1$.
Translated by QwenWork