33OJ
登录 注册

#P13980. 数列分块入门 5

    ID: 15780 远端评测题 2000ms 512MiB 尝试: 5 已通过: 4 显示难度提高 上传者: 标签>暴力数据结构线段树分块

数列分块入门 5

Background

The constraints of the testdata in Luogu's "Introduction to Sequence Block Decomposition" series differ from those of the original problems.

Problem Description

You are given a sequence a1…ana_1 \ldots a_n of length nn and nn operations. The operations involve range square root and range sum.

Input Format

The first line contains one integer nn.

The second line contains nn integers, where the ii-th integer is aia_i, separated by spaces.

Then nn lines follow, each containing a query. Each line contains three integers opt,l,r\mathrm{opt}, l, r, separated by spaces.

If opt=0\mathrm{opt} = 0, it means that every number in [l,r][l, r] is replaced by its square root. For each aia_i in the range (l≤i≤r)(l \le i \le r), $a_i \leftarrow \left\lfloor \sqrt{a_i}\right\rfloor$.

If opt=1\mathrm{opt} = 1, it means that you should query the sum of all numbers in [l,r][l, r].

Output Format

For each query, output one integer on a single line giving the answer.

4
1 2 2 3
0 1 3
1 1 4
0 1 2
1 1 2
6
2

Hint

Subtasks

Subtask 1 (40 points): 1≤n≤500001 \leq n \leq 50000, 0≤ai,ans≤231−10 \leq a_i, \mathrm{ans} \leq 2^{31}-1.

Subtask 2 (60 points): 1≤n≤3000001 \leq n \leq 300000, 0≤ai≤231−10 \leq a_i \leq 2^{31}-1, 0≤ans≤263−10 \leq \mathrm{ans} \leq 2^{63}-1.

For all testdata, 1≤n≤3000001 \leq n \leq 300000 and 0≤ai≤231−10 \leq a_i \leq 2^{31}-1, 0≤ans≤263−10 \leq \mathrm{ans} \leq 2^{63}-1. 1≤l≤r≤n1 \leq l \leq r \leq n. opt∈{0,1}\mathrm{opt} \in \{0,1\}, 1≤l≤r≤n1 \leq l \leq r \leq n. After each operation every aia_i satisfies 0≤ai≤231−10 \leq a_i \leq 2^{31}-1.

Translated by QwenWork