309130: CF1629B. GCD Arrays

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

GCD Arrays

题意翻译

### 题目描述 考虑一下数组 $a$,范围是 $[l,r]$。例如,$[3,7]$,数组 $a$ 就是 $[3,4,5,6,7]$。 给出 $l,r,k$,询问 $gcd(a)$ 是否能在最多 $k$ 次如下 操作以后比 1 大? * 在 $a$ 数组中选择两个数。 * 删除这两个数。 * 将这两个数的乘积放回数组 $a$。 其中,$gcd(b)$ 意思就是 $b$ 数组中数字的[最大公因数](https://baike.baidu.com/item/%E6%9C%80%E5%A4%A7%E5%85%AC%E7%BA%A6%E6%95%B0/869308?fromtitle=%E6%9C%80%E5%A4%A7%E5%85%AC%E5%9B%A0%E6%95%B0&fromid=869104&fr=aladdin) ### 输入格式 第一行包含一个整数 $t (1 \le t \le 10^5)$,表示数据组数。 接下来 $t$ 行,每行三个正整数 $l,r,k (1 \le l,r \le 10^9;0 \le k \le r - l)$,含义如题。 ### 输出格式 对于每组数据,如果能在 1 到 $k$ 步求出日题意的最大公因数,那么输出 `YES`,否则输出 `NO`。 ### 说明提示 对于样例输入的第 1 组测试数据,$a = [1]$,所以输出 `NO`,因为 1 是数组 $a$ 的唯一元素。 对于样例输入的第 2 组数据,数组 $a = [3,4,5]$,现在我们有 1 次操作机会。不难发现,无论如何操作,结果只会有 3 个:$[3,20],[4,15],[5,12]$,他们的最大公因数都是 1,没有其他的数,所以输出 `NO`。 对于样例输入的第 3 组测试数据,$a = [13]$,所以输出 `YES`,因为唯一的元素就是 13,一个质数。 对于样例输入的第 4 组数据,$a = [4]$,输出 `YES`,因为 4 是唯一的元素。

题目描述

Consider the array $ a $ composed of all the integers in the range $ [l, r] $ . For example, if $ l = 3 $ and $ r = 7 $ , then $ a = [3, 4, 5, 6, 7] $ . Given $ l $ , $ r $ , and $ k $ , is it possible for $ \gcd(a) $ to be greater than $ 1 $ after doing the following operation at most $ k $ times? - Choose $ 2 $ numbers from $ a $ . - Permanently remove one occurrence of each of them from the array. - Insert their product back into $ a $ . $ \gcd(b) $ denotes the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of the integers in $ b $ .

输入输出格式

输入格式


The first line of the input contains a single integer $ t $ ( $ 1 \le t \le 10^5 $ ) — the number of test cases. The description of test cases follows. The input for each test case consists of a single line containing $ 3 $ non-negative integers $ l $ , $ r $ , and $ k $ ( $ 1 \leq l \leq r \leq 10^9, \enspace 0 \leq k \leq r - l $ ).

输出格式


For each test case, print "YES" if it is possible to have the GCD of the corresponding array greater than $ 1 $ by performing at most $ k $ operations, and "NO" otherwise (case insensitive).

输入输出样例

输入样例 #1

9
1 1 0
3 5 1
13 13 0
4 4 0
3 7 4
4 10 3
2 4 0
1 7 3
1 5 3

输出样例 #1

NO
NO
YES
YES
YES
YES
NO
NO
YES

说明

For the first test case, $ a = [1] $ , so the answer is "NO", since the only element in the array is $ 1 $ . For the second test case the array is $ a = [3, 4, 5] $ and we have $ 1 $ operation. After the first operation the array can change to: $ [3, 20] $ , $ [4, 15] $ or $ [5, 12] $ all of which having their greatest common divisor equal to $ 1 $ so the answer is "NO". For the third test case, $ a = [13] $ , so the answer is "YES", since the only element in the array is $ 13 $ . For the fourth test case, $ a = [4] $ , so the answer is "YES", since the only element in the array is $ 4 $ .

Input

题意翻译

### 题目描述 考虑一下数组 $a$,范围是 $[l,r]$。例如,$[3,7]$,数组 $a$ 就是 $[3,4,5,6,7]$。 给出 $l,r,k$,询问 $gcd(a)$ 是否能在最多 $k$ 次如下 操作以后比 1 大? * 在 $a$ 数组中选择两个数。 * 删除这两个数。 * 将这两个数的乘积放回数组 $a$。 其中,$gcd(b)$ 意思就是 $b$ 数组中数字的[最大公因数](https://baike.baidu.com/item/%E6%9C%80%E5%A4%A7%E5%85%AC%E7%BA%A6%E6%95%B0/869308?fromtitle=%E6%9C%80%E5%A4%A7%E5%85%AC%E5%9B%A0%E6%95%B0&fromid=869104&fr=aladdin) ### 输入格式 第一行包含一个整数 $t (1 \le t \le 10^5)$,表示数据组数。 接下来 $t$ 行,每行三个正整数 $l,r,k (1 \le l,r \le 10^9;0 \le k \le r - l)$,含义如题。 ### 输出格式 对于每组数据,如果能在 1 到 $k$ 步求出日题意的最大公因数,那么输出 `YES`,否则输出 `NO`。 ### 说明提示 对于样例输入的第 1 组测试数据,$a = [1]$,所以输出 `NO`,因为 1 是数组 $a$ 的唯一元素。 对于样例输入的第 2 组数据,数组 $a = [3,4,5]$,现在我们有 1 次操作机会。不难发现,无论如何操作,结果只会有 3 个:$[3,20],[4,15],[5,12]$,他们的最大公因数都是 1,没有其他的数,所以输出 `NO`。 对于样例输入的第 3 组测试数据,$a = [13]$,所以输出 `YES`,因为唯一的元素就是 13,一个质数。 对于样例输入的第 4 组数据,$a = [4]$,输出 `YES`,因为 4 是唯一的元素。

加入题单

算法标签: