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.
If you r using cin or cout then paste this line in main function first- "ios::sync_with_stdio(0);
always use scanf and printf for IO operations in spoj questions
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