Problem in GCDSET May cookoff

Nope… {22} gcd is not 11

But that’s unfair. It feels like cheating. Although I applied the most suitable logic, still getting WA.:cry:

Thanks you are saying correct my submission also got accepted.

Problem is precision issue… Try printing floor( (10^18-1)/10^18) you will get 1 instead of 0

1 Like

Nothing is unfair… Don’t use inbuilt ceil and floor while handling very large values…
If you have then in p/q for use your own ceil and floor… (double)p/q may create precision issue… Check floor((double )(10^18-1)/10^18))

And why it is not unfair? The logic was correct, Implementation was correct, getting WA due to some precision issue???

Implementation was incorrect…you can’t store it in double… Use big double library then it’s fine…

I did in Python, still getting WA.
My solution

I’m also getting WA. Here is my Java solution.
https://ideone.com/6zueXo
Can anyone give me a counter-example that breaks my solution? Thanks!

Try for l=6,r=10 and g=4. Correct answer is 0, but your code give output 1.

1 Like

1RVJjW - Online Python3 Interpreter & Debugging Tool - Ideone.com

Check this… I doubt that you are using big decimal…

i am so unhappy right now because i did not know that python ceil() would give me wrong answer…

6
3 4 3
6 7 3
2 10 3
3 10 3
2 9 3
3 9 3

Answers are
1
0
3
3
3
3
Ping me if you need more test cases

You are right, here is the mistake of mine. Thanks!

1 Like

That is why you do competitive bro… That is what you need to learn…

There is an issue in division in python. Have a look:

Thanks for your help though.:+1:

1 Like

To better understand why this fails check —>: Unofficial editorial for GCDSET

For those having used (as me) floor and ceil function improperly, this test could help:
1
4611686018427387902 4611686018427387903 1

Answer should be:
2

Hope this helps.

This prob seems interesting
cant wait to try this after my exams