CF1519A.Red and Blue Beans

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You have rr red and bb blue beans. You'd like to distribute them among several (maybe, one) packets in such a way that each packet:

  • has at least one red bean (or the number of red beans ri≥1r_i \ge 1);
  • has at least one blue bean (or the number of blue beans bi≥1b_i \ge 1);
  • the number of red and blue beans should differ in no more than dd (or ∣ri−bi∣≤d|r_i - b_i| \le d)

Can you distribute all beans?

你有 rr 颗红色豆子和 bb 颗蓝色豆子。你想将它们分装到若干个(可能只有一个)袋子中,使得每个袋子:

  • 至少包含一颗红色豆子(即红色豆子数量 ri≥1r_i \ge 1);
  • 至少包含一颗蓝色豆子(即蓝色豆子数量 bi≥1b_i \ge 1);
  • 红色豆子与蓝色豆子的数量之差不超过 dd(即 ∣ri−bi∣≤d|r_i - b_i| \le d)。

你能将所有豆子都分装完毕吗?

输入格式

The first line contains the single integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases.

The first and only line of each test case contains three integers rr, bb, and dd (1≤r,b≤1091 \le r, b \le 10^9; 0≤d≤1090 \le d \le 10^9) — the number of red and blue beans and the maximum absolute difference in each packet.

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 测试用例的数量。

每个测试用例仅有一行,包含三个整数 rr、bb 和 dd(1≤r,b≤1091 \le r, b \le 10^9;0≤d≤1090 \le d \le 10^9)—— 分别表示红色豆子和蓝色豆子的数量,以及每个包装袋中两种豆子数量的绝对差的最大允许值。

输出格式

For each test case, if you can distribute all beans, print YES. Otherwise, print NO.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).

对于每个测试用例,如果你能分发完所有豆子,则输出 YES;否则输出 NO。

你可以以任意大小写形式输出每个字母(例如,字符串 yEs、yes、Yes 和 YES 均被视为肯定回答)。

输入输出样例

  • 输入#1

    4
    1 1 0
    2 7 3
    6 1 4
    5 4 0

    输出#1

    YES
    YES
    NO
    NO

说明/提示

In the first test case, you can form one packet with 11 red and 11 blue bean. The absolute difference ∣1−1∣=0≤d|1 - 1| = 0 \le d.

In the second test case, you can form two packets: 11 red and 44 blue beans in the first packet and 11 red and 33 blue beans in the second one.

In the third test case, since b=1b = 1, you can form only one packet with 66 red and 11 blue beans. The absolute difference ∣6−1∣=5>d|6 - 1| = 5 \gt d.

In the fourth test case, since d=0d = 0 so each packet should contain the same number of red and blue beans, but r≠br \neq b.

在第一个测试用例中,你可以组成一个包含 11 颗红色豆子和 11 颗蓝色豆子的包裹。其绝对差值 ∣1−1∣=0≤d|1 - 1| = 0 \le d。

在第二个测试用例中,你可以组成两个包裹:第一个包裹包含 11 颗红色豆子和 44 颗蓝色豆子,第二个包裹包含 11 颗红色豆子和 33 颗蓝色豆子。

在第三个测试用例中,由于 b=1b = 1,你只能组成一个包含 66 颗红色豆子和 11 颗蓝色豆子的包裹。其绝对差值 ∣6−1∣=5>d|6 - 1| = 5 \gt d。

在第四个测试用例中,由于 d=0d = 0,因此每个包裹必须包含相同数量的红色豆子和蓝色豆子,但 r≠br \neq b。

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

首页