#P2122. 还教室
还教室
Description
During the days when rental requests were accepted, on day there are classrooms remaining. As the person in charge of the university classroom rental service, you need to perform operations of the following three types:
- From day to day , classrooms are returned each day.
- Query the average number of classrooms from day to day .
- Query the variance of the number of classrooms from day to day .
Input Format
The first line contains two positive integers and , where is the number of days and is the number of operations.
The next line contains integers; the -th integer indicates that on day the number of remaining classrooms is .
The next lines: each line starts with the operation code (only , , or ), followed by two positive integers and . If the operation code is , then an additional positive integer follows.
Output Format
For each operation of type and type , output the answer as a reduced fraction (the numerator and denominator are coprime). In particular, if the answer is , output .
5 4
1 2 3 4 5
1 1 2 3
2 2 4
3 2 4
3 1 5
4/1
2/3
14/25
Hint
For all testdata, , , , , and the number of type operations does not exceed .
Note: The small ranges of and , and the small number of type operations, are intended to ensure that the numerator of the answer will not be large, preventing overflow beyond the -bit integer range; this is unrelated to the intended solution.
Translated by ChatGPT 5
京公网安备 11011102002149号