Hello Codeforces,
Just got TLE on 2116C - Гелифиш и пылающий пион using __gcd, but after switching to gcd from <numeric>, my code got AC!
TLE Submission (using __gcd): Submission #322284306
AC Submission (using std::gcd): Submission #322321593
I couldn't find a clear reason online for this difference.
If anyone knows why this happens, please share in the comments section!








Auto comment: topic has been updated by Barakat. (previous revision, new revision, compare).
There's this blog where this guy explain some things about the 2 versions of gcd, since he was having some problems with it too. Might be a good reading (it was for me at least).
in c++17 __gcd is faster than gcd but in c++20 and c++23 gcd is faster than __gcd
Why people even use an internal implementation when there is literal standard one??
They have different implementations (Euclid vs binary) and sometimes
__gcdis better in complex situationsremove long long you should get ac even with __gcd() due to log factor going till 64x this causes the time limit to get exceeded
I did submit the same code without long long during the contes. It still gave me TLE
i saw it your approach is different i'm talking about the recursive dp may there is some bug in your code other than __gcd also try initialising your dp size to max of elements not directly 5001