Codeforces Round 969 (Div. 2)
A
Dora's Set
Codeforces
800
原题
←B →
翻译中…

Dora has a set $s$ containing integers. In the beginning, she will put all integers in $[l, r]$ into the set $s$. That is, an integer $x$ is initially contained in the set if and only if $l \leq x \leq r$. Then she allows you to perform the following operations:

翻译中…
  • Select three distinct integers $a$, $b$, and $c$ from the set $s$, such that $\gcd(a, b) = \gcd(b, c) = \gcd(a, c) = 1^\dagger$.
  • Then, remove these three integers from the set $s$.
翻译中…

What is the maximum number of operations you can perform?

翻译中…

$^\dagger$Recall that $\gcd(x, y)$ means the greatest common divisor of integers $x$ and $y$.

翻译中…

Input

翻译中…

Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 500$) — the number of test cases. The description of the test cases follows.

翻译中…

The only line of each test case contains two integers $l$ and $r$ ($1 \leq l \leq r \leq 1000$) — the range of integers in the initial set.

翻译中…

Output

翻译中…

For each test case, output a single integer — the maximum number of operations you can perform.

翻译中…

Note

翻译中…

In the first test case, you can choose $a = 1$, $b = 2$, $c = 3$ in the only operation, since $\gcd(1, 2) = \gcd(2, 3) = \gcd(1, 3) = 1$, and then there are no more integers in the set, so no more operations can be performed.

翻译中…

In the second test case, you can choose $a = 3$, $b = 5$, $c = 7$ in the only operation.

翻译中…

In the third test case, you can choose $a = 11$, $b = 19$, $c = 20$ in the first operation, $a = 13$, $b = 14$, $c = 15$ in the second operation, and $a = 10$, $b = 17$, $c = 21$ in the third operation. After the three operations, the set $s$ contains the following integers: $12$, $16$, $18$. It can be proven that it's impossible to perform more than $3$ operations.

翻译中…

样例

Input #1
8
1 3
3 7
10 21
2 8
51 60
2 15
10 26
1 1000
Output #1
1
1
3
1
2
3
4
250
InputCopy OutputCopy
题目信息
题号
2007A
时间限制
1 s
内存限制
256 MB
标签
贪心
数学
数论

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