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;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM