copyPasteCoder's blog

By copyPasteCoder, history, 13 hours ago, In English

For the problem 2043D - Problem about GCD,

  • 298543362 — using $$$gcd$$$ function — gives AC (578 ms)
  • 298543382 — using __$$$gcd$$$ function — gives TLE

I was earlier told that by my friends and mentors that __gcd is faster than gcd. Can anyone tell where did I go wrong $$$?$$$
  • Vote: I like it
  • +39
  • Vote: I do not like it

»
13 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

I had a similar experience, and like you, I took a time limit with __gcd time limit and exported it with GCD. This is because GCD uses the recursion method and takes much less time than normal

  • »
    »
    13 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    So, can this make that much difference $$$?$$$
    On doing private mashup, I got running time as 1312ms (more than twice).

»
13 hours ago, # |
  Vote: I like it +9 Vote: I do not like it

Link Here someone had the opposite result than you.

»
12 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

It's weird, from my testing, it seems like:

gcd(X % Y, Y) < __gcd(X, Y) < gcd(X, Y)

in terms of runtime

»
9 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

I had the same experience, but I saw this post before submission so I changed __gcd to gcd after getting TLE and got accepted. But this makes me confused about which one to use!!