Stock
题号:NC15936
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 64 M,其他语言128 M
64bit IO Format: %lld

题目描述

There are n stocks in the market, and after researching, the variance of the i-th stock’s price is ai per dollar you devoted.

Master Dong is reluctant to taking risk, so he wants to put the money on hand into n shares in a certain proportion, so that the total amount of total investment in all stocks fluctuates to a minimum.

We use the variance as a measure of volatility. We assume the money Master Dong invested into stocks is a real number. And we just define the unit minimum variance (UMV) as the variance of each dollar Mater Dong invested, under the optimal strategy.

There are m days now. For each day we have a cmd.

cmd = 1 indicates that the market was uniformly regulated on that day, and the stock price was adjusted by x% for the stocks from l to r.

cmd = 2 means if only stocks l to r are considered, what is UMV.

It’s guaranteed the answer is a rational number in the form of .  You only need to output in order to avoid accuracy error and high precision.

, all inputs are integers.

输入描述:

The first line contains two intergers : n, m.

The next line contains n integers a1…an

The next m lines: first input cmd if cmd = 1, input
l, r, x, or l ,r.

输出描述:

For every cmd = 2, output an integer in a line.
示例1

输入

复制
5 4
1 2 3 4 5
2 1 2
2 1 5
1 2 3 2
2 1 5

输出

复制
666666672
503649639
24407394