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 $$$?$$$
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
So, can this make that much difference $$$?$$$
On doing private mashup, I got running time as 1312ms (more than twice).
Link Here someone had the opposite result than you.
It's weird, from my testing, it seems like:
gcd(X % Y, Y) < __gcd(X, Y) < gcd(X, Y)
in terms of runtime
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!!
apparently
std::gcd(a%b, b)
is the fastest