Codeforces Round 924 (Div. 2)
C
Physical Education Lesson
Codeforces
1600
原题
← BD →
翻译中…

In a well-known school, a physical education lesson took place. As usual, everyone was lined up and asked to settle in "the first–$k$-th" position.

翻译中…

As is known, settling in "the first–$k$-th" position occurs as follows: the first $k$ people have numbers $1, 2, 3, \ldots, k$, the next $k - 2$ people have numbers $k - 1, k - 2, \ldots, 2$, the next $k$ people have numbers $1, 2, 3, \ldots, k$, and so on. Thus, the settling repeats every $2k - 2$ positions. Examples of settling are given in the "Note" section.

翻译中…

The boy Vasya constantly forgets everything. For example, he forgot the number $k$ described above. But he remembers the position he occupied in the line, as well as the number he received during the settling. Help Vasya understand how many natural numbers $k$ fit under the given constraints.

翻译中…

Note that the settling exists if and only if $k \gt 1$. In particular, this means that the settling does not exist for $k = 1$.

翻译中…

Input

翻译中…

Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 100$) — the number of test cases. This is followed by the description of the test cases.

翻译中…

The only line of each test case contains two integers $n$ and $x$ ($1 \le x \lt n \le 10^9$) — Vasya's position in the line and the number Vasya received during the settling.

翻译中…

Output

翻译中…

For each test case, output a single integer — the number of different $k$ that fit under the given constraints.

翻译中…

It can be proven that under the given constraints, the answer is finite.

翻译中…

Note

翻译中…

In the first test case, $k$ equals $2, 3, 5, 6$ are suitable.

翻译中…

An example of settling for these $k$:

翻译中…

$k$ / №$1$$2$$3$$4$$5$$6$$7$$8$$9$$10$$2$$1$$2$$1$$2$$1$$2$$1$$2$$1$$2$$3$$1$$2$$3$$2$$1$$2$$3$$2$$1$$2$$5$$1$$2$$3$$4$$5$$4$$3$$2$$1$$2$$6$$1$$2$$3$$4$$5$$6$$5$$4$$3$$2$

翻译中…

In the second test case, $k = 2$ is suitable.

翻译中…

样例

Input #1
5
10 2
3 1
76 4
100 99
1000000000 500000000
Output #1
4
1
9
0
1
InputCopy OutputCopy
题目信息
题号
1928C
时间限制
1 s
内存限制
256 MB
标签
暴力
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。