nsists of three integers I, r, and m, find out the product of elements goodArrayfly through goodArrayir] modulo mwhen goodArray I sorted in non-decreasing order. Example For N = 26, queries = [11, 2, 10091, [3, 3, 511 goodArray when sorted is [2,8,16]. For query I = 1, r = 2, m = 1009, ans = goodArray(1] * goodArrayf2] = (2 * 8) modulo 1009 = 16. For query / = 3, r = 3, m = 5, ans = goodArray = (16) modulo 5 = 1.
For a number N, a goodArray is the smallest possible array that consists of only powers of two (2°,21 ... 2k) such that the sum of all the numbers in the array is equal to N.
For each query that consists of three integers I, r, and m, find out the product of elements goodArrayfly through goodArrayir] modulo mwhen goodArray I sorted in non-decreasing order.
Example
For N = 26, queries = [11, 2, 10091, [3, 3, 511
goodArray when sorted is [2,8,16].
For query I = 1, r = 2, m = 1009, ans =
goodArray(1] * goodArrayf2] = (2 * 8) modulo
1009 = 16.
For query / = 3, r = 3, m = 5, ans = goodArray =
(16) modulo 5 = 1.
The answer is [16, 1].
Function Description
Complete the function getQueryResults
the code is an given below :
Step by step
Solved in 3 steps with 1 images