×

# Editorial/Submissions request for ARMYFGT

 0 It seemed an easy problem. I even took care of edge cases I think. I don't know why I'm getting WA. Will the submissions be made public? asked 31 Dec '18, 00:18 65●4 accept rate: 0%

 0 You are not considering the probability of overflow in lcm. I also got a wrong answer verdict for the same condition. My accepted solution link is Solution Link answered 31 Dec '18, 12:55 135●5 accept rate: 30% it was not what you said but it had to do with the lcm! I use ceil function in the code and when lcm got very very large, ceil(1/lcm), which i expected to give 1, gave 0. thanks! (31 Dec '18, 23:55) got AC! thanks. (01 Jan, 00:05)
 0 Do you have the link to the problem and your attempted solution? answered 31 Dec '18, 00:21 106●3 accept rate: 13% Here is the problem. Here is my solution. (31 Dec '18, 09:59)
 0 What is the LCM overflow condition? Can you explain a bit? answered 31 Dec '18, 17:13 1 accept rate: 0% let we have found lcm upto index i - 1. Then for our current index i , lcm would be lcm = (lcm*arr[i]) / (gcd(arr[i] , lcm)) Here you are multiplying two possibly large numbers which could extend upto number more than 10^9. These would lead to overflow since long long is also not capable of holding such large numbers. So I have kept a condition which would not let number to exceed my upper bound. The condition for the same is if (R < (lcm*arr[i]) . gcd(lcm , arr[i])) then break my loop. The further simplification can be seen in the code which I have linked in my answer. Hope this helps. :) (31 Dec '18, 19:55)
 0 If anyone's interested in C++ solution - Link answered 01 Jan, 10:58 171●1●7 accept rate: 5%
 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:

×15,852
×3
×1

question asked: 31 Dec '18, 00:18

question was seen: 343 times

last updated: 02 Jan, 18:56