#P1438. Arithmetic Sequence Operations

    ID: 14724 Type: Default 1000ms 256MiB

Arithmetic Sequence Operations

Arithmetic Sequence Operations

You are given a sequence \(a_i\) (initially all zeros) of length \(n\) and you need to process \(m\) operations. There are two types of operations:

  • 1 l r K D: For indices \(l \leq i \leq r\), add an arithmetic sequence to \(a_i\) such that \(a_l\) is increased by \(K\), \(a_{l+1}\) by \(K+D\), and in general \(a_i\) is increased by \(K + (i-l)\times D\). Formally, for every \(i\) from \(l\) to \(r\), perform \[ a_i \mathrel{+}= K + (i-l) \times D \]
  • 2 p: Output the current value of \(a_p\).

It is guaranteed that the operations are valid. Process all operations in order.

inputFormat

The first line contains two integers \(n\) and \(m\) representing the length of the sequence and the number of operations.

The following \(m\) lines each represent an operation:

  • Operation of the first type is given as: 1 l r K D.
  • Operation of the second type is given as: 2 p.

outputFormat

For each operation of the second type, output the value of \(a_p\) on a separate line.

sample

5 5
1 1 3 1 2
2 2
1 2 5 2 1
2 3
2 5
3

8 5

</p>