CF1629B.GCD Arrays

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Consider the array aa composed of all the integers in the range [l,r][l, r]. For example, if l=3l = 3 and r=7r = 7, then a=[3,4,5,6,7]a = [3, 4, 5, 6, 7].

Given ll, rr, and kk, is it possible for gcd⁡(a)\gcd(a) to be greater than 11 after doing the following operation at most kk times?

  • Choose 22 numbers from aa.
  • Permanently remove one occurrence of each of them from the array.
  • Insert their product back into aa.

gcd⁡(b)\gcd(b) denotes the greatest common divisor (GCD) of the integers in bb.

考虑由区间 [l,r][l, r] 内所有整数构成的数组 aa。例如,若 l=3l = 3 且 r=7r = 7,则 a=[3,4,5,6,7]a = [3, 4, 5, 6, 7]。

给定 ll、rr 和 kk,在最多执行以下操作 kk 次后,是否可能使 gcd⁡(a)>1\gcd(a) > 1?

  • 从 aa 中选择 22 个数;
  • 永久地从数组中各移除其中一个数的一次出现;
  • 将这两个数的乘积重新插入 aa 中。

gcd⁡(b)\gcd(b) 表示数组 bb 中所有整数的最大公约数(GCD)。

输入格式

The first line of the input contains a single integer tt (1≤t≤1051 \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 33 non-negative integers ll, rr, and kk (1≤l≤r≤109,0≤k≤r−l1 \leq l \leq r \leq 10^9, \enspace 0 \leq k \leq r - l).

输入的第一行包含一个整数 tt(1≤t≤1051 \le t \le 10^5),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的输入为一行,包含三个非负整数 ll、rr 和 kk(1≤l≤r≤109,0≤k≤r−l1 \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 11 by performing at most kk operations, and "NO" otherwise (case insensitive).

对于每个测试用例,如果可以通过执行至多 kk 次操作使得对应数组的最大公约数(GCD)大于 11,则输出 "YES";否则输出 "NO"(不区分大小写)。

输入输出样例

  • 输入#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]a = [1], so the answer is "NO", since the only element in the array is 11.

For the second test case the array is a=[3,4,5]a = [3, 4, 5] and we have 11 operation. After the first operation the array can change to: [3,20][3, 20], [4,15][4, 15] or [5,12][5, 12] all of which having their greatest common divisor equal to 11 so the answer is "NO".

For the third test case, a=[13]a = [13], so the answer is "YES", since the only element in the array is 1313.

For the fourth test case, a=[4]a = [4], so the answer is "YES", since the only element in the array is 44.

对于第一个测试用例,a=[1]a = [1],因此答案为“NO”,因为数组中唯一的元素是 11。

对于第二个测试用例,数组为 a=[3,4,5]a = [3, 4, 5],且我们有 11 次操作。第一次操作后,数组可变为:[3,20][3, 20]、[4,15][4, 15] 或 [5,12][5, 12],这些数组的最大公约数均为 11,因此答案为“NO”。

对于第三个测试用例,a=[13]a = [13],因此答案为“YES”,因为数组中唯一的元素是 1313。

对于第四个测试用例,a=[4]a = [4],因此答案为“YES”,因为数组中唯一的元素是 44。

输入解题思路,AI测评打分。不知道怎么写?

首页