7223: Gcd Problem

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,(1,2)=1,(12,18)=6.
(a,b) can be easily found by the Euclidean algorithm. Now Carp is considering a little more difficult problem:
Given integers N and M, how many integer X satisfies 1<=X<=N and (X,N)>=M.

输入

The first line of input is an integer T(T<=1000) representing the number of test cases. The following T lines each contains two numbers N and M (2<=N,M<=10^10), representing a test case.

输出

For each test case,output the answer on a single line.

样例输入 复制

3
1 1
10 2
10000 72

样例输出 复制

1
6
260

提示

In the first test case , gcd(1,1)=1 >= 1 ,so answer is 1.
In the second test case , gcd(10,2)=gcd(10,4)=gcd(10,6)=gcd(10,8)=2,gcd(10,5)=5,gcd(10,10)=10 , so answer is 6.