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.
Input
First line of input: T (Number of test cases)
In next T lines, each have one pair A B (0 < A, B <= 10^6)
Output
One integer describing number of common divisors between two numbers.
Example
Input: 3
100000 100000
12 24
747794 238336
Output: 36
6
2
hide comments
Harpreet Singh Khurana:
20120119 08:37:00
can somebody give some more test cases with boundary cases included......is (0,0) also included Last edit: 20120119 08:37:52 

Albert Chen:
20111128 20:17:32
************Warning***********


Hazem:
20111109 22:48:15
i use


??????????????:
20111108 07:22:52
when checking upto (min(a,b))/2 TLE is coming.plz.somebody help me 

ontole:
20111031 16:43:33
sqrt(min(a,b)) is giving tle!!! 

Yasser Kamel:
20111006 16:49:29
i spend a day for this :


sri:
20111005 19:47:39
O(sqrt(min(x,y)) is getting TLE???


Dante is not a Geek:
20110713 14:11:10
Can you give a test case where my code fails? I do not understand why there can be overflow for such small numbers. Submission ID: 5374241 Last edit: 20110714 01:10:56 

Psycho:
20110627 16:46:07
@radhakrishnan u r comparing it wit finding prime which can be done in (sqrt(n)) but here, I think its solution requires at least O(min(x,y)) time correct me if i am wrong 

Egor:
20110627 16:46:07
Solution with 0(n/2 + lnln(n)) is ok on pascal =)

Added by:  Mir Wasi Ahmed 
Date:  20101031 
Time limit:  0.600s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Own problem, used in UODA TST 