SP11840 SEGSQRSS - Sum of Squares with Segment Tree

Description

Segment trees are extremely useful. In particular "Lazy Propagation" (i.e. [see here, for example](http://stackoverflow.com/questions/10832954/data-mapping-and-lazy-propagation-in-segment-tree)) allows one to compute sums over a range in O(lg(n)), and update ranges in O(lg(n)) as well. In this problem you will compute something much harder: **The sum of squares over a range with range updates of 2 types:** **1) increment in a range** **2) set all numbers the same in a range.**

Input Format

There will be **T** (**T**

Output Format

For each test case output the “Case :” in the first line and from the second line output the sum of squares for each operation of type 2. Intermediate overflow will not occur with proper use of 64-bit signed integer.