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.
Only a single cin and cout will cost you TLE don't need to seive just find gcd and then count divisor
Here is a note about comparing the same solution speed across different programming languages:
using scanf and printf instead of cin and cout could help!
WTH How can using cout instead of printf cost a WALast edit: 2019-03-18 17:47:35
I don't what to do anymore --- should I use cin, cout or scanf ,printf
this was wayy more easy than i thought,
Just use scanf and printf for I/O , avoid cin & cout in C++ costed me TLE.
What's the application of gcd in this problem??
AC in 3rd go , just use fast input/output , no need to build sieve , just find factors for every test case in O(sqrt(n))Last edit: 2018-10-14 17:51:15