P6327 Range Add and Range Sine Sum

Description

Given an integer sequence $a_1,a_2,\ldots,a_n$ of length $n$, perform $m$ operations. There are two types of operations. Operation $1$: given $l,r,v$, add $v$ to each of $a_l,a_{l+1},\ldots,a_r$. Operation $2$: given $l,r$, query $\sum\limits_{i=l}^{r}\sin(a_i)$.

Input Format

The first line contains an integer $n$. The next line contains $n$ integers representing $a_1,a_2,\ldots,a_n$. The next line contains an integer $m$. The next $m$ lines each describe an operation. Operation $1$ is written as `1 l r v`, and operation $2$ is written as `2 l r`.

Output Format

For each operation $2$, output one line with the answer, rounded to one decimal place. It is guaranteed that the absolute value of the answer is greater than $0.1$, and that the second digit after the decimal point of the exact answer is not $4$ or $5$.

Explanation/Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: ccz181078, Data: nzhtl1477. Constraints: $1\leq n,m,a_i,v\leq 2\times 10^5$, $1\leq l\leq r\leq n$. It is guaranteed that all input numbers are positive integers. Translated by ChatGPT 5