Given an array, answer queries for of elements in range .
Example: arr - Query : - Query : is idempotent: .
So the overlap trick works. Just change the merge operation from to . Constraints: up to elements, up to queries.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
GCD is idempotent
Given an array, answer queries for of elements in range .
Example: arr - Query : - Query : is idempotent: .
So the overlap trick works. Just change the merge operation from to . Constraints: up to elements, up to queries.