×

# My approach for SMRSTR(November Lunchtime)

 0 Problem:- SMRSTR It says that we have to optimize the code snippet given in the problem. We can observe that for every value in the X array we do the same thing by dividing it repeatedly by all the elements in the D array i.e we just divide every value in the X array by the product of all elements in the D array. So, we can proceed by finding this product only once. But according to the constraints the product results in a very big number. But we can observe that if product is greater than the largest element in X array, then answer becomes zero for all of them. So, we stop calculating the product when it crosses the largest element in X array. Since, largest element in the X array satisfies our constraints, we can ensure that our product doesn't overflow. If the product does not exceed the largest element of X array we simply find it and divide it with all the elements of the X array and print the result. This gives us a runtime of O(n) which is enough for this question. If there is a better approach, please do comment it. Here is a link to my solution:- Click Here If anyone did solve the second problem L-R queries, please explain me. Thanks. asked 26 Nov '17, 00:33 2★ramini 61●5 accept rate: 8% 0★admin ♦♦ 19.7k●350●498●541 @ramini Refer to this thread for LR queries: https://discuss.codechef.com/questions/118551/discuss-your-approach-november-lunchtime (26 Nov '17, 01:02) avi2244★ Thanks bro!!! (26 Nov '17, 01:06) ramini2★

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×145
×98
×16
×4

question asked: 26 Nov '17, 00:33

question was seen: 551 times

last updated: 26 Nov '17, 16:15