Loading

Educational Codeforces Round 108 (Rated for Div. 2) A. Red and Blue Beans(思维)

You have r red and b 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≥1);
  • has at least one blue bean (or the number of blue beans bi≥1);
  • the number of red and blue beans should differ in no more than 𝑑d (or |ri−bi|≤d)

Can you distribute all beans?

Input

The first line contains the single integer 𝑡t (1≤t≤1000) — the number of test cases.

The first and only line of each test case contains three integers r, b, and d (1≤r,b≤109; 0≤d≤109) — the number of red and blue beans and the maximum absolute difference in each packet.

Output

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).

Example

input

Copy

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

output

Copy

YES
YES
NO
NO

不妨设r > b,首先求出来r和b的差值,然后贪心地分配(先保证每个包红蓝个数都是b,然后把多的r平均分配,看看能否满足条件即可。

#include <bits/stdc++.h>
using namespace std;
int main() {
	int t;
	cin >> t;
	while(t--) {
		long long r, b, d;
		cin >> r >> b >> d;
		long long x = min(r, b), diff = abs(r - b);
		if(ceil(diff * 1.0 / x) <= d) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}
posted @ 2021-04-30 09:01  脂环  阅读(452)  评论(0编辑  收藏  举报