COMDIV - Number of common divisors
You will be given T (T<=10^6) pair of numbers. All you have to tell is the number of common divisors between two numbers in each pair.
First line of input: T (Number of test cases)
In next T lines, each have one pair A B (0 < A, B <= 10^6)
One integer describing number of common divisors between two numbers.
std::__gcd(n,k) and printf/scanf pave the way for ac!! :)
calculating gcd with euclidean gave tle but with std::__gcd(n,k) ac
TLE when using cin and cout but got AC on using printf and scanf..
sometimes thinking too much is dangerous :( 2 TLEs for too much thinking
easy one for c++
easy ac in one go :)
Woo.. Fast input too takes 0.36 seconds.. O(sqrt(gcd(a, b)) using the std::__gcd available in C++.. Any hint on how to make it faster ??Last edit: 2016-01-11 17:06:33
std::__gcd(n,k) under <algorithm> ...can be used to get gcd without defining any function!
tle in c