3145. Find Products of Elements of Big Array

A

powerful arrayfor an integer`x`

is the shortest sorted array of powers of two that sum up to`x`

. For example, the powerful array for 11 is`[1, 2, 8]`

.The array

`big_nums`

is created by concatenating thepowerfularrays for every positive integer`i`

in ascending order: 1, 2, 3, and so forth. Thus,`big_nums`

starts as`[1, 2, 1, 2, 4, 1, 4, 2, 4, 1, 2, 4, 8, ...]`

.You are given a 2D integer matrix

`queries`

, where for`queries[i] = [fromi, toi, modi]`

you should calculate`(big_nums[fromi] * big_nums[fromi + 1] * ... * big_nums[toi]) % modi`

.Return an integer array

`answer`

such that`answer[i]`

is the answer to the`ith`

query.