#P12854. [NERC 2020 Online] Easy Measurements

[NERC 2020 Online] Easy Measurements

题目描述

Edward was tasked to measure the pumping rate of two water pumps. To do so, he used the pumps to pump water into a water tank and checked how much water was pumped into the tank in a specific time.

He found out that the first pump pumps aa liters of water in bb seconds, and the second pump pumps cc liters of water in dd seconds. He also discovered that when both pumps are used at the same time, together they pump bb liters of water in dd seconds.

Unfortunately, Edward has spilled some water on his records, so now he can't recover the values aa and cc. However, he remembers that these values were positive integers. Now he wonders how many ways are there to choose the values aa and cc that are consistent with his measurements.

输入格式

The first line contains an integer nn (1n10001\le n\le1000) --- the number of test cases.

Each of the next nn lines contains two integers bb and dd (1b,d1091\le b,d\le10^9).

输出格式

For each test case, output a single integer --- the number of ways to choose aa and cc. Output each answer on a separate line.

3
9 6
40 60
60 40
4
13
29

提示

In the first test case, the possible values are a=3a=3, c=7c=7; a=6a=6, c=5c=5; a=9a=9, c=3c=3; and a=12a=12, c=1c=1.