1743: How Many Common Divisors?
Problem
This is a simple problem, given two positive integers M and N, how may common divisors do they have?
For example, M = 24, N = 36; M and N have 6 common divisors, they are 1,2,3,4,6,12.
It is guaranteed that no common divisor of M and N will be larger than 500,000 in the input.
Input
Input contains multiple test cases. The first line of the input is an integer T (T <= 20000) representing the number of test cases, followed by T lines, each line contains two positive integers M, N.
Output
For each test case, print the total number of common divisors.
Sample Input
1
24 36
Sample Output
6
我能够做出答案,但总是超时,帮忙看看
Problem
This is a simple problem, given two positive integers M and N, how may common divisors do they have?
For example, M = 24, N = 36; M and N have 6 common divisors, they are 1,2,3,4,6,12.
It is guaranteed that no common divisor of M and N will be larger than 500,000 in the input.
Input
Input contains multiple test cases. The first line of the input is an integer T (T <= 20000) representing the number of test cases, followed by T lines, each line contains two positive integers M, N.
Output
For each test case, print the total number of common divisors.
Sample Input
1
24 36
Sample Output
6
我能够做出答案,但总是超时,帮忙看看