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.
use printf & scanf instead of cout & cin, costed me 2 TLELast edit: 2019-12-29 20:43:54
The trick here is that, the divisors of the gcd(a, b) is the answer [Let a, b be the given pair].
cout gave me accepted and printf gave me WA. :)
My 50th on SPOJ!!
if u r using cin and cout then copy this lines
find gcd, and dont use printf
Nice problem :)
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!