Today I am share my new experience . I am trying to solve a problem in SPOJ. Problem link:https://www.spoj.com/problems/COMDIV/ When I solve this problem using C++ it gives TLE for simple code. For this problem my solving approach was at first find the GCD of two values than from 1 to GCD I use a loop if any number is divided by that than i count it for two time without corner case. But it gives me Time Limited Exceed. I really become astonished to see this. Than just i convert it into c . instead of cin use scanf and instead of cout use printf than it accept the code. Truly it was a bad experience for me in problem solving.
just number of divisors of gcd
This will give you TLE
yeah because that's sqrt(1e6) * 1e6 = 1e9
learn sieve of eratosthenes
Oh! Thanks! I didn’t think that way. My pleasure for your instruction.
But i have a question why this this solution excepted
luck? dunno, there's still a simple solution that passes comfortably.