• [1560] Let Slimes Grow Up

  • 时间限制: 5000 ms 内存限制: 65535 K
  • 问题描述
  • You know 8Mao has his own Slime Team. But he soon found that let the Slimes stand in a line and make them from low to high is a such stupid thing since the Slimes are so f[bi][bi]king stupid!
    As a result, 8Mao decided to give up.
    But 8Mao still want his Slime Team be beautiful. So he got up another idea, let his Slimes grow up. He got some medicine that can make the Slimes in the line get higher. But only can let continuous Slimes.
    8Mao thought that the variance of the heights of Slimes in the line is smaller, the Slime Team is more beautiful.
    You have to help 8Mao to calculate out the variance of Slimes in a continuous sequence.
  • 输入
  • This problem contains several cases, ends with EOF.
    The first line of each case contains 2 integers N and M which N indicates the number of Slimes and the number of operations.
    Next line contains the heights of each Slimes ordered from 0 ~ N - 1. (0 < height <= 100, 000)
    Then M lines followed. Each line indicates one operation.
    If the operator is "1", then follows 3 integers A, B and C which indicate the start number of the Slimes and the end number of the Slimes and the heights the Slimes between A and B will increase.
    If the operator is "2", then follows 2 integers A and B, you have to calculate out the variance of heights between Slime A and Slime B.
  • 输出
  • For each operator "2", you should output the variance. (The answer should be formatted to integer)
  • 样例输入
  • 5 3
    1 4 3 2 5
    2 0 4
    1 1 2 2
    2 0 4
    
  • 样例输出
  • 2
    3
    
  • 提示
  • 来源
  • cjl
  • 操作

显示春菜