#P3707. [SDOI2017] 相关分析
[SDOI2017] 相关分析
Description
Frank is very interested in astronomy. He often observes stars with a telescope and records their information, such as brightness and color, and then estimates properties like distance and radius.
Frank not only enjoys observing but also analyzing the data he collects. He often checks whether there is some relationship between two parameters (for example, brightness and radius).
Now Frank wants to analyze the relationship between parameters and . He has groups of observations. The -th group records and . He needs to perform the following types of operations.
Fit a line to the observations from group to group . Let denote the mean of among these observations, and let denote the mean of , that is,
$$\begin{aligned}\overline{x}&={1 \over R-L+1} \sum _{i=L} ^R x_i \\\overline{y}&={1 \over R-L+1} \sum _{i=L} ^R y_i\end{aligned}$$If the line equation is , then should be computed as:
$$a={\displaystyle\sum_{i=L} ^R (x_i-\overline{x})(y_i-\overline{y}) \over \displaystyle\sum _{i=L} ^R (x_i -\overline{x})^2}$$You need to help Frank compute .
Frank found that the measurements from group to group have errors. For each with , add to and add to .
Frank needs to modify the data from group to group . For each with , set to and set to .
Input Format
The first line contains two numbers , denoting the number of observation groups and the number of operations.
The next line contains numbers, where the -th number is .
The next line contains numbers, where the -th number is .
The next lines describe the operations. See the formats in the problem statement.
Output Format
For each operation of type , output one line containing the slope . Your output is considered correct if the absolute or relative error does not exceed .
3 5
1 2 3
1 2 3
1 1 3
2 2 3 -3 2
1 1 2
3 1 2 2 1
1 1 3
1.0000000000
-1.5000000000
-0.6153846154
Hint
Constraints and Notes
- For of the testdata, .
- For another of the testdata, there is no operation , and in operation we have .
- For another of the testdata, there is no operation .
For of the testdata, , , .
It is guaranteed that in operation the denominator will not be .
Translated by ChatGPT 5
京公网安备 11011102002149号