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.
cout, cin gave me few TLE and then god knows what gave me WA - finally correct !
Using cin,cout along with fast ip/op passed in every problem I have solved so far,so never used scanf,printf in a C++ code, but here I don't know why using scanf,printf becomes a compulsion.This thing annoys me a lot.If anyone can help,pls help me know that what's the use of "ios_base::sync_with_stdio(false); cin.tie(NULL) in a c++ code" if we always have to use scanf,printfLast edit: 2017-03-21 16:19:59
AC in 1 go with c++ cin,cout working fine in 0.35 sec
Lovely concept! Initially I was brute-forcing but the comments were really helpful!
i hate when it gives tle due to cin cout.......
EDIT: FYI for C++ users
java = TLE
100th =D ... #printf/scanf
Cool, for C# I can't even parse the input without a TLE.
try this one with spoj input 4 16 output: 3