Taking square root with segment tree

Revision en3, by RubenAshughyan, 2019-02-26 21:30:28

Hi everyone, Today I enconted a data structures problem, which is a slight swist on standart segment tree problem.

You are given an array A of size N. N ≤ 10^5, A[i] ≤ 10^6, You need yo process 3 types of queries

1. Print the sum of all integers ai where L ≤ i ≤ R.

2. Add x to each integer ai where L ≤ i ≤ R.

3. For each integer A[i] where L ≤ i ≤ R, replace it with floor(sqrt(A[i])). Where sqrt(a) is the square root of a, and floor(b) is the integer value of b after removing everything on the right of the decimal point.

If we didn't have type 3 query, then we are left with standard lazy segment tree problem.

How to handle 3rd type queries?

#### History

Revisions

Rev. Lang. By When Δ Comment
en6 RubenAshughyan 2019-02-26 21:35:42 3 Tiny change: 'day I enconted a data ' -> 'day I encountered a data '
en5 RubenAshughyan 2019-02-26 21:32:08 2 Tiny change: 'i everyone,\nToday I ' -> 'i everyone.\nToday I '
en4 RubenAshughyan 2019-02-26 21:31:43 37
en3 RubenAshughyan 2019-02-26 21:30:28 13 Tiny change: '. _N ≤ 100000, A[i] ≤ 1000000,_\nYou ne' -> '. _N ≤ 10^5, A[i] ≤ 10^6,_\nYou ne'
en2 RubenAshughyan 2019-02-26 21:29:54 8
en1 RubenAshughyan 2019-02-26 21:29:03 737 Initial revision (published)