#P6327. Sine Sum Queries on Dynamic Array
Sine Sum Queries on Dynamic Array
Sine Sum Queries on Dynamic Array
You are given an integer sequence \(a_1,a_2,\ldots,a_n\) of length \(n\) and \(m\) operations. There are two types of operations:
- Operation 1: Given \(l, r, v\), add \(v\) to each element \(a_l, a_{l+1}, \ldots, a_r\).
- Operation 2: Given \(l, r\), output \(\displaystyle\sum_{i=l}^{r} \sin(a_i)\).
Note: The sine function uses radian measure.
inputFormat
The first line contains two integers \(n\) and \(m\) representing the length of the sequence and the number of operations.
The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\).
Each of the following \(m\) lines describes an operation in one of the following two forms:
1 l r v
: Add \(v\) to each element \(a_i\) for \(l \le i \le r\).2 l r
: Print \(\displaystyle\sum_{i=l}^{r} \sin(a_i)\).
outputFormat
For each operation of type 2, output the value of \(\displaystyle\sum_{i=l}^{r} \sin(a_i)\) on a new line. Answers with an absolute or relative error of at most \(10^{-6}\) will be accepted.
sample
5 3
1 2 3 4 5
2 1 5
1 2 4 1
2 1 5
0.17606165
-1.69205000
</p>