LCC '22 Contest 6 S4 - Motivation

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem types

After finding out that N of Metropolis' team members have been procrastinating on their work, Patrick has come up with a system to "motivate" them.

Patrick has tied up the N people (who are numbered 1 to N) at angular positions of \theta_1, \theta_2, ..., \theta_N degrees on a circular wheel. As his indentured servant, Jimmy's job is to facilitate the "motivation" by taking Q orders from him, of the following form:

  • 1 L R D Spin every person in the range [L, R] by D degrees counter-clockwise. This means that D should be added to \theta_L, \theta_{L+1}, ..., \theta_R.
  • 2 L R To make sure that Jimmy has been obeying his orders, he must compute the sum \cos(\theta_L) + \cos(\theta_{L+1}) + ... + \cos(\theta_R) for the current angular positions.

Unfortunately, as an indentured servant, Jimmy was not allowed an education. Please help him answer the queries lest he suffers Patrick's wrath.

Constraints

In all subtasks,

1 \le N, Q \le 10^5

1 \le L_i \le R_i \le N

0 \le \theta_i, D_i < 360

Subtask 1 [30%]

1 \le N, Q \le 1000

Subtask 2 [70%]

No further constraints.

Input Specification

The first line will contain two space-separated integers, N and Q.

The next line will contain N space-separated decimal numbers, \theta_1, \theta_2, ..., \theta_N in degrees.

The next Q lines will each contain one order with the format specified above.

Output Specification

For each order of type 2, output the answer on a new line.

Output your answers to 3 decimal places. Your answers will be considered correct if their absolute or relative errors do not exceed 10^3.

Sample Input

5 3
0.00 30.00 60.00 90.00 180.00
2 1 3
1 3 4 45.00
2 2 5

Sample Output

2.366
-1.100

Comments

There are no comments at the moment.