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

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

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

Post by answerhappygod »

For A Number N A Goodarray Is The Smallest Possible Array That Consists Of Only Powers Of Two 20 2 2k Such That 1
For A Number N A Goodarray Is The Smallest Possible Array That Consists Of Only Powers Of Two 20 2 2k Such That 1 (82.34 KiB) Viewed 217 times
can i have an answer in python?
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 I, r, and m, find out the product of elements goodArray[!] 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 Constraints 1 ≤ N≤ 1018 • 1≤q≤105 1 sms 105 • 1 ≤l≤rs goodArray), where goodArray/ denotes the length of the array
Input Format For Custom Testing Sample Case 0 Sample Input For Custom Testing STDIN 63 FUNCTION 0 4 2 → N = 6 ➜ q 3 3 1 2 4 228 1 14 Sample Output q[] size = 3 → queries [[1,2,4], [2,2,8], [1,1,4]]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply