1. GoodArray For a number N, a goodArray is the smallest possible array that consists of only powers of two (20, 2¹ ...

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1. GoodArray For a number N, a goodArray is the smallest possible array that consists of only powers of two (20, 2¹ ...

Post by answerhappygod »

1 Goodarray For A Number N A Goodarray Is The Smallest Possible Array That Consists Of Only Powers Of Two 20 2 1
1 Goodarray For A Number N A Goodarray Is The Smallest Possible Array That Consists Of Only Powers Of Two 20 2 1 (40.53 KiB) Viewed 137 times
1 Goodarray For A Number N A Goodarray Is The Smallest Possible Array That Consists Of Only Powers Of Two 20 2 2
1 Goodarray For A Number N A Goodarray Is The Smallest Possible Array That Consists Of Only Powers Of Two 20 2 2 (40.53 KiB) Viewed 137 times
1. GoodArray For a number N, a goodArray is the smallest possible array that consists of only powers of two (20, 2¹ ... 2k) such that the sum of all the numbers in the array is equal to N. For each query that consists of three integers /, r, and m, find out the product of elements goodArray[1] through goodArray[r] modulo m when goodArray is sorted in non- decreasing order. Example For N = 26, queries = [[1, 2, 1009], [3, 3, 5]] goodArray when sorted is [2,8,16]. For query /= 1, r = 2, m= 1009, ans = goodArray[1] * goodArray[2] = (2*8) modulo 1009 = 16. For query /= 3, r = 3, m=5, ans = goodArray3 = (16) modulo 5 = 1. The answer is [16, 1]. Function Description Complete the function getQueryResults in the editor below. getQueryResults has the following parameters: long N: the integer N int queries[q][3]: a 2D array of queries, each with 3 elements I, r, and m. Return int answer[q]: the answers to the queries
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply