問題一覧 > 通常問題

No.3507 RangeSum RangeUpdate RangeSqrt

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 39
作問者 : n_bitand_n_per_3 / テスター : Naru820 Nzt3 rhoo Solalyth
お気に入りにしたユーザー ProblemId : 13165 / 自分の提出
問題文最終更新日: 2026-04-17 20:32:41
RangeSum RangeUpdate RangeSqrt
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
CPCTF 2026: PPC (順位表) の他の問題:

Problem Statement

You are given an array $A=(A_0,A_1,...,A_{N-1})$ of length $N$. Here, each $A_i$ is an integer greater than or equal to $0$.

Process a total of $Q$ queries of the following $3$ types. Here, $\text{isqrt}(x)$ is the function that returns the integer part of $\sqrt{x}$, that is, $\text{isqrt}(x) := \left\lfloor \sqrt{x}\right\rfloor$.

  • 0 l r : Output $\ A_l+A_{l+1}+...+A_{r-1}$.
  • 1 l r x : Assign $x$ to $\ A_l,A_{l+1},...,A_{r-1}$.
  • 2 l r : Apply $\text{isqrt}$ to all of $\ A_l,A_{l+1},...,A_{r-1}$. That is, for every $i$ satisfying $l \le i < r$, replace $A_i$ with $\text{isqrt}(A_i)$.

Constraints

  • $1 \le N \le 10^5$
  • $1 \le Q \le 10^5$
  • $0 \le A_i \le 10^9$
  • $0 \le l \le r \le N$
  • $0 \le x\le 10^9$
  • All input values are integers.

Input

The input is given from standard input in the following format.
$N$ $Q$
$A_0$ $A_1$ ... $A_{N-1}$
$\text{query}_1$
$\text{query}_2$
...
$\text{query}_Q$

Here, $\text{query}_i$ represents the $i$-th query and is given in one of the following formats.

$0 ~ l ~ r$
$1 ~ l ~ r ~ x$
$2 ~ l ~ r$

Output

Let $k$ be the number of queries of the first type. Output $k$ lines. On the $i$-th line, output the answer to the $i$-th query of the first type.

Sample

Sample 1
Input
6 4
1 2 3 4 5 6
0 1 4
1 0 3 10
2 1 3
0 1 4
Output
9
10

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。