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 @   脂环  阅读(454)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示
主题色彩