logo AlgoBeat OnlineJudge
登录 注册

#212921. [NERC 2020 Online] Easy Measurements

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 liters of water in seconds, and the second pump pumps liters of water in seconds. He also discovered that when both pumps are used at the same time, together they pump liters of water in seconds.

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

输入格式

The first line contains an integer () --- the number of test cases.

Each of the next lines contains two integers and ().

输出格式

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

样例

样例输入 1

3
9 6
40 60
60 40

样例输出 1

4
13
29

数据范围与提示

In the first test case, the possible values are , ; , ; , ; and , .