Segment tree with updates? When the update segment contains the segment of the node, we should be able to update LCM and GCD in ~constant time, but I can hardly see any obvious way to calculate LCM(a+p,b+p,c+p,…,z+p) from the previous value…