# [SOLUTION] Red and Blue Beans solution codeforces – You have rr red and bb blue beans – 2021

## Red and Blue Beans solution

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

Can you distribute all beans?

Input : Red and Blue Beans solution

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

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

Output : Red and Blue Beans solution

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 yEsyesYes and YES are all recognized as positive answer).

Example : Red and Blue Beans solution

input

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


output

YES
YES
NO
NO

Note : Red and Blue Beans solution

In the first test case, you can form one packet with 11 red and 11 blue bean. The absolute difference |11|=0d|1−1|=0≤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 |61|=5>d|6−1|=5>d.

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

Program Code :

## PYTHON

for _ in range(int(input())):
r,b,d=map(int,input().split())
if max(r,b)<=min(r,b)*(d+1):
print("YES")
else:
print("NO")

## RUST

#![warn(
clippy::all,
rust_2018_idioms,
missing_copy_implementations,
missing_debug_implementations,
trivial_casts,
unused_import_braces,
unused_qualifications,
unused_results
)]
#![allow(
clippy::many_single_char_names,
non_snake_case,
unused_imports,
unused_macros,
)]

#[cfg(not(test))]
macro_rules! println {
($($tt:tt)*) => {
let _ = ($($tt)*);
};
}

#[cfg(not(test))]
macro_rules! print {
($($tt:tt)*) => {
let _ = ($($tt)*);
};
}

use crate::io::Io;
use crate::util::*;
use crate::*;
use core::cmp::Ordering::{Equal, Greater, Less};
use core::cmp::{max, min};
use core::iter::{empty, once, repeat, FromIterator};
use core::mem::swap;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, LinkedList, VecDeque};

pub const MODE: Mode = Mode::Multiple;

pub fn solution<B: BufRead + Write>(io: &mut Io<B>) {
//const N_MAX: usize = 100;
//let mut a = [0; N_MAX];
//let a: Vec<(i64, i64)> = io.read_n_pairs(n).collect();
//let a: Vec<(i64, i64, i64)> = io.read_n_triplets(n).collect();
//let a: Vec<i64> = (0..n).map(|_| io.read()).collect();
//println!("{:?}", [false, true].map_bools("1", "0").concat_to_string());

if r == b {
io.yes();
} else {
let m = min(r, b);
let x = max(r, b);
if m + d * m >= x {
io.yes();
} else {
io.no();
}
}
}

#[cfg(test)]
fn alternative<B: BufRead + Write>(io: &mut Io<B>) {

io.writeln(n + m);
}

#[cfg(test)]
#[test]
fn test_example() {
let output = |input: &str| output_for(|io| solution(io), MODE, &input);
assert_eq!(
output(
"4
1 1 0
2 7 3
6 1 4
5 4 0"
),
"YES
YES
NO
NO"
.reformat_with_trim(),
);
}

#[cfg(test)]
#[test]
fn test_custom() {
let output = |input: &str| output_for(|io| solution(io), Mode::Single, &input);
assert_eq!(output("1 1 0"), "YES\n");
assert_eq!(output("1 2 0"), "NO\n");
assert_eq!(output("1 3 0"), "NO\n");
assert_eq!(output("1 4 0"), "NO\n");
assert_eq!(output("1 5 0"), "NO\n");
assert_eq!(output("1 6 0"), "NO\n");
assert_eq!(output("1 7 0"), "NO\n");
assert_eq!(output("1 8 0"), "NO\n");
assert_eq!(output("1 9 0"), "NO\n");

assert_eq!(output("1 2 2"), "YES\n");
assert_eq!(output("1 3 2"), "YES\n");
assert_eq!(output("1 4 2"), "NO\n");
assert_eq!(output("1 5 2"), "NO\n");
assert_eq!(output("1 6 2"), "NO\n");
assert_eq!(output("1 7 2"), "NO\n");
assert_eq!(output("1 8 2"), "NO\n");
assert_eq!(output("1 9 2"), "NO\n");

assert_eq!(output("2 2 2"), "YES\n");
assert_eq!(output("2 3 2"), "YES\n");
assert_eq!(output("2 4 2"), "YES\n");
assert_eq!(output("2 5 2"), "YES\n");
assert_eq!(output("2 6 2"), "YES\n");
assert_eq!(output("2 7 2"), "NO\n");
assert_eq!(output("2 8 2"), "NO\n");
assert_eq!(output("2 9 2"), "NO\n");

assert_eq!(output("2 2 3"), "YES\n");
assert_eq!(output("2 3 3"), "YES\n");
assert_eq!(output("2 4 3"), "YES\n");
assert_eq!(output("2 5 3"), "YES\n");
assert_eq!(output("2 6 3"), "YES\n");
assert_eq!(output("2 7 3"), "YES\n");
assert_eq!(output("2 8 3"), "YES\n");
assert_eq!(output("2 9 3"), "NO\n");

assert_eq!(output("2 2 3"), "YES\n");
assert_eq!(output("3 2 3"), "YES\n");
assert_eq!(output("4 2 3"), "YES\n");
assert_eq!(output("5 2 3"), "YES\n");
assert_eq!(output("6 2 3"), "YES\n");
assert_eq!(output("7 2 3"), "YES\n");
assert_eq!(output("8 2 3"), "YES\n");
assert_eq!(output("9 2 3"), "NO\n");
}

/*#[cfg(test)]
#[test]
fn test_matched() {
let matched = |input: &str| matched_for(
|io| solution(io), |io| alternative(io), Mode::Single, &input,
);
}*/

/*#[cfg(test)]
#[test]
fn test_matched() {
// require each join_to_string
let matched = |input: &str| {
matched_for(
|io| solution(io),
|io| alternative(io),
Mode::Single,
&input,
)
};
for j in 2..=2 {
for args in vec![1..=10; j].each() {
let input = format!("{}", args.join_to_string(" "));
matched(&input);
}
}
}*/
}

pub fn main() {

let mut writer = BufWriter::new(stdout());
let mut io = Io::new(IoPair::new(&mut reader, &mut writer));
solve(solution, MODE, &mut io);
io.flush();
}

use ceil::*;
mod ceil {

use crate::div_euclid::DivEuclid;
use crate::one::One;

#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Ceil<T>(pub T);

impl<T> Div<T> for Ceil<T>
where
T: Add<Output = T> + Clone + DivEuclid + One + Sub<Output = T>,
{
type Output = T;

fn div(self, rhs: T) -> Self::Output {
(self.0 + rhs.clone() - T::one()).div_euclid(rhs)
}
}
}

use into_vec::*;
mod into_vec {
pub trait IntoVec<T> {
fn into_vec(self) -> Vec<T>;
}

impl<I, T> IntoVec<T> for I
where
Self: Sized,
I: IntoIterator<Item = T>,
{
fn into_vec(self) -> Vec<T> {
self.into_iter().collect()
}
}
}

use io::*;
mod io {
use std::fmt::{Debug, Display};

#[derive(Clone, Debug)]
pub struct IoPair<R, W> {
writer: W,
}

#[derive(Clone, Debug)]
pub struct Io<B> {
io: B,
is_writer_bol: bool,
}

impl<R, W> IoPair<R, W> {
pub fn new(reader: R, writer: W) -> Self {
}

pub fn writer_ref(&self) -> &W {
&self.writer
}
}

fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
}
}

fn fill_buf(&mut self) -> io::Result<&[u8]> {
}

fn consume(&mut self, amt: usize) {
}
}

impl<R, W: Write> Write for IoPair<R, W> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.writer.write(buf)
}

fn flush(&mut self) -> std::io::Result<()> {
self.writer.flush()
}
}

impl<B: BufRead + Write> Io<B> {
pub fn new(io: B) -> Self {
Self {
io,
is_writer_bol: true,
}
}

pub fn get_ref(&self) -> &B {
&self.io
}

pub fn get_mut(&mut self) -> &mut B {
&mut self.io
}

pub fn try_read_str(&mut self) -> Result<&str, io::Error> {
loop {
} else {
let mut end = start + 1;
while end < self.reader_line.len() && !line[end].is_ascii_whitespace() {
end += 1;
}
let word = unsafe { std::str::from_utf8_unchecked(&line[start..end]) };
return Ok(word);
}
}
}

pub fn try_read<T: std::str::FromStr>(&mut self) -> Result<T, io::Error>
where
<T as std::str::FromStr>::Err: Debug,
{
}

pub fn try_read_ascii(&mut self) -> Result<&[u8], io::Error> {
}

pub fn try_read_decimal(&mut self) -> Result<impl '_ + Iterator<Item = u8>, io::Error> {
}

&mut self,
one: u8,
) -> Result<impl '_ + Iterator<Item = bool>, io::Error> {
}

pub fn read_str(&mut self) -> &str {
}

pub fn read<T: std::str::FromStr>(&mut self) -> T
where
<T as std::str::FromStr>::Err: Debug,
{
}

pub fn read_n<T: std::str::FromStr>(&mut self, n: usize) -> impl '_ + Iterator<Item = T>
where
<T as std::str::FromStr>::Err: Debug,
{
}

pub fn read_n_pairs<T1: std::str::FromStr, T2: std::str::FromStr>(
&mut self,
n: usize,
) -> impl '_ + Iterator<Item = (T1, T2)>
where
<T1 as std::str::FromStr>::Err: Debug,
<T2 as std::str::FromStr>::Err: Debug,
{
}

T1: std::str::FromStr,
T2: std::str::FromStr,
T3: std::str::FromStr,
>(
&mut self,
n: usize,
) -> impl '_ + Iterator<Item = (T1, T2, T3)>
where
<T1 as std::str::FromStr>::Err: Debug,
<T2 as std::str::FromStr>::Err: Debug,
<T3 as std::str::FromStr>::Err: Debug,
{
}

pub fn read_ascii(&mut self) -> &[u8] {
}

pub fn read_decimal(&mut self) -> impl '_ + Iterator<Item = u8> {
}

pub fn read_bits(&mut self, one: u8) -> impl '_ + Iterator<Item = bool> {
}

pub fn write<T: Display>(&mut self, value: T) -> &mut Self {
if self.is_writer_bol {
write!(self.io, "{}", value).unwrap();
} else {
write!(self.io, " {}", value).unwrap();
}
self.is_writer_bol = false;
self
}

pub fn writeln<T: Display>(&mut self, value: T) {
if self.is_writer_bol {
writeln!(self.io, "{}", value).unwrap();
} else {
writeln!(self.io, " {}", value).unwrap();
}
self.is_writer_bol = true;
}

pub fn write_all<T: Display, U: IntoIterator<Item = T>>(&mut self, iter: U) -> &mut Self {
for value in iter.into_iter() {
let _ = self.write(value);
}
self
}

pub fn writeln_all<T: Display, U: IntoIterator<Item = T>>(&mut self, iter: U) {
self.write_all(iter).ln();
}

pub fn write_ascii(&mut self, bytes: &[u8]) -> &mut Self {
self.write(std::str::from_utf8(bytes).unwrap())
}

pub fn writeln_ascii(&mut self, bytes: &[u8]) {
self.write_ascii(bytes).ln();
}

pub fn write_join<T: Display>(&mut self, value: T) -> &mut Self {
write!(self.io, "{}", value).unwrap();
self.is_writer_bol = false;
self
}

pub fn ln(&mut self) {
writeln!(self.io).unwrap();
self.is_writer_bol = true;
}

pub fn yes(&mut self) {
self.writeln("YES");
}

pub fn no(&mut self) {
self.writeln("NO");
}

pub fn flush(&mut self) {
let _ = self.io.flush();
}

pub fn writeln_flush<T: Display>(&mut self, value: T) {
self.writeln(value);
self.flush();
}

pub fn writeln_all_flush<T: Display, U: IntoIterator<Item = T>>(&mut self, iter: U) {
self.writeln_all(iter);
self.flush();
}

pub fn ln_flush(&mut self) {
self.ln();
self.flush();
}
}
}

use target::*;
mod target {
#[cfg(test)]
#[test]
fn test_32bit_target() {
use core::mem::size_of;
assert_eq!(size_of::<usize>(), 4, "Codeforces use 32-bit targets");
}
}

use to_iterator::*;
mod to_iterator {
pub trait ToIterator: Clone + IntoIterator {
fn to_iter(&self) -> Self::IntoIter;
}

impl<T> ToIterator for T
where
T: Clone + IntoIterator,
{
fn to_iter(&self) -> Self::IntoIter {
self.clone().into_iter()
}
}
}

use to_vec::*;
mod to_vec {
use crate::to_iterator::ToIterator;

pub trait ToVec<T> {
fn to_vec(&self) -> Vec<T>;
}

impl<I, T> ToVec<T> for I
where
Self: Sized,
I: ToIterator<Item = T>,
{
fn to_vec(&self) -> Vec<T> {
self.to_iter().collect()
}
}
}

use util::*;
mod util {
use std::io::Write;

use crate::io::{Io, IoPair};

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Mode {
Single, // If only the single test case is expected
Multiple, // If multiple test cases are expected
}

pub fn solve<F, B>(func: F, mode: Mode, io: &mut Io<B>)
where
F: Fn(&mut Io<B>),
{
match mode {
Mode::Single => {
func(io);
io.flush();
}
Mode::Multiple => {
for _ in 0..n {
func(io);
io.flush();
}
}
}
}

pub fn output_for<F>(func: F, mode: Mode, input: &str) -> String
where
F: Fn(&mut Io<IoPair<&[u8], Vec<u8>>>),
{
let writer = Vec::new();
let mut io = Io::new(IoPair::new(reader, writer));
solve(func, mode, &mut io);
std::str::from_utf8(io.get_ref().writer_ref())
.unwrap()
.to_string()
}

#[cfg(test)]
pub fn matched_for<F1, F2>(solution: F1, alternative: F2, mode: Mode, input: &str)
where
F1: Fn(&mut Io<IoPair<&[u8], Vec<u8>>>),
F2: Fn(&mut Io<IoPair<&[u8], Vec<u8>>>),
{
assert_eq!(
output_for(|io| solution(io), mode, input),
output_for(|io| alternative(io), mode, input),
"Where left is solution, right is alternative, and input is: {}",
input
);
}

#[cfg(test)]
pub fn join_to_string<T, I>(items: I) -> String
where
T: ToString,
I: IntoIterator<Item = T>,
{
items
.into_iter()
.map(|item| item.to_string())
.collect::<Vec<_>>()
.join(" ")
}

pub trait ReformatWithTrim {
fn reformat_with_trim(self) -> String;
}

impl ReformatWithTrim for &str {
fn reformat_with_trim(self) -> String {
let lines: Vec<String> = self
.trim()
.lines()
.map(|line| line.trim_start().to_string())
.collect();
lines.join("\n") + "\n"
}
}

pub trait FormatBits {
fn pm_fmt(self) -> String;
}

impl FormatBits for &[bool] {
fn pm_fmt(self) -> String {
self.iter()
.map(|item| if *item { "+" } else { "-" })
.collect()
}
}
}

use div_euclid::*;
mod div_euclid {
pub trait DivEuclid {
fn div_euclid(self, rhs: Self) -> Self;
}

macro_rules! impl_ops {
($($type:tt)*) => {
$( impl DivEuclid for$type {
fn div_euclid(self, rhs: Self) -> Self {
self.div_euclid(rhs)
}
}
)*
};
}

impl_ops!(u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);
}

use one::*;
mod one {
pub trait One {
fn one() -> Self;
fn is_one(&self) -> bool;
}

macro_rules! impl_ops {
($($type:tt)*) => {
$( impl One for$type {
fn one() -> Self {
1
}

fn is_one(&self) -> bool {
*self == 1
}
}
)*
};
}

impl_ops!(u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);
}

## C++

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef uint64_t bu;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpl;
typedef vector<string> vs;
typedef vector<char> vc;
#define vb vector<bool>
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define LB lower_bound
#define UB upper_bound
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repr(i, a, b) for (ll i = a; i > b; i--)
#define rept(type, i, a, op, b, change) for (type i = a; i op b; i += change) //general for loop
#define repi(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define cy cout << "YES"<<endl
#define cn cout<<"NO"<<endl
#define F first
#define S second
#define PI 3.14159265358979323846
#define W(i,n) while(i<n)
#define Sort(v) sort(begin(v),end(v))
#define M 998244353
#define MAXN 1000001
#define MOD 1000000007
#define all(v) begin(v),end(v)
#define elif else if
#define INF 1000000000000000003
#define INFF LLONG_MAX
#define debug(x) cout<<"#x:"<<x<<endl
//ll spf[MAXN];
bool is_Smaller_str(string str1, string str2)
{
// Calculate lengths of both string
ll n1 = str1.length(), n2 = str2.length();

if (n1 < n2)
return true;
if (n2 < n1)
return false;

for (int i=0; i<n1; i++)
if (str1[i] < str2[i])
return true;
else if (str1[i] > str2[i])
return false;

return false;
}
// Graph class represents a undirected graph
class Graph {
// No. of vertices
int V;

// Pointer to an array containing adjacency lists

// A function used by DFS
void DFSUtil(int v, bool visited[]);

public:
// Constructor
Graph(int V);

int NumberOfconnectedComponents();
};

// Function to return the number of
// connected components in an undirected graph
int Graph::NumberOfconnectedComponents()
{

// Mark all the vertices as not visited
bool* visited = new bool[V];

// To store the number of connected components
int count = 0;
for (int v = 0; v < V; v++)
visited[v] = false;

for (int v = 0; v < V; v++) {
if (visited[v] == false) {
DFSUtil(v, visited);
count += 1;
}
}

return count;
}

void Graph::DFSUtil(int v, bool visited[])
{

// Mark the current node as visited
visited[v] = true;

// Recur for all the vertices
list<int>::iterator i;

if (!visited[*i])
DFSUtil(*i, visited);
}

Graph::Graph(int V)
{
this->V = V;
}

{
}
// Function for find difference of larger numbers
string find_Diff_str(string str1, string str2)
{
// Before proceeding further, make sure str1
// is not smaller
if (is_Smaller_str(str1, str2))
swap(str1, str2);

// Take an empty string for storing result
string str = "";

// Calculate length of both string
ll n1 = str1.length(), n2 = str2.length();

// Reverse both of strings
reverse(str1.begin(), str1.end());
reverse(str2.begin(), str2.end());

ll carry = 0;

// Run loop till small string length
// and subtract digit of str1 to str2
for (ll i=0; i<n2; i++)
{
// Do school mathematics, compute difference of
// current digits

ll sub = ((str1[i]-'0')-(str2[i]-'0')-carry);

// If subtraction is less then zero
// take carry as 1 for calculating next step
if (sub < 0)
{
sub = sub + 10;
carry = 1;
}
else
carry = 0;

str.push_back(sub + '0');
}

// subtract remaining digits of larger number
for (ll i=n2; i<n1; i++)
{
ll sub = ((str1[i]-'0') - carry);

// if the sub value is -ve, then make it positive
if (sub < 0)
{
sub = sub + 10;
carry = 1;
}
else
carry = 0;

str.push_back(sub + '0');
}

// reverse resultant string
reverse(str.begin(), str.end());

return str;
}
string find_sum_str(string str1, string str2)
{
// Before proceeding further, make sure length
// of str2 is larger.
if (str1.length() > str2.length())
swap(str1, str2);

// Take an empty string for storing result
string str = "";

// Calculate length of both string
int n1 = str1.length(), n2 = str2.length();

// Reverse both of strings
reverse(str1.begin(), str1.end());
reverse(str2.begin(), str2.end());

int carry = 0;
for (int i=0; i<n1; i++)
{
// Do school mathematics, compute sum of
// current digits and carry
int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
str.push_back(sum%10 + '0');

// Calculate carry for next step
carry = sum/10;
}

// Add remaining digits of larger number
for (int i=n1; i<n2; i++)
{
int sum = ((str2[i]-'0')+carry);
str.push_back(sum%10 + '0');
carry = sum/10;
}

if (carry)
str.push_back(carry+'0');

// reverse resultant string
reverse(str.begin(), str.end());

return str;
}

void FAST() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll Rselect(vector<ll> v, ll i, ll l, ll r); //finding the ith order statistic
ll partition(vector<ll> v, ll l, ll r);
void scanc(vc& v,ll n)
{
rep(i,0,n)
{
char num;
cin>>num;
v.pub(num);
}
}
void scanP(vpl& v,ll n)
{
rep(i,0,n)
{
ll num1,num2;
cin>>num1>>num2;
pair<ll,ll> p = {num1,num2};
v.pub(p);
}
}
template<typename T>
ostream& operator<<(ostream& stream, const vector<T>& vec) //outputting a vector
{
for (auto& i : vec)
{
stream << i << ' ';
}
stream << '\n';
return stream;
}

template<class T>
istream& operator>>(istream& stream, vector<T>& vec) //input for vectors of fixed size
{
for (auto& i : vec)
{
stream >> i;
}
return stream;
}

void solve();

/*void sieve()
{
spf[1] = 1;
for (ll i=2; i<MAXN; i++)

// marking smallest prime factor for every
// number to be itself.
spf[i] = i;

// separately marking spf for every even
// number as 2
for (ll i=4; i<MAXN; i+=2)
spf[i] = 2;

for (ll i=3; i*i<MAXN; i++)
{
// checking if i is prime
if (spf[i] == i)
{
// marking SPF for all numbers divisible by i
for (ll j=i*i; j<MAXN; j+=i)

// marking spf[j] if it is not
// previously marked
{
if (spf[j]==j)
spf[j] = i;
}
}
}
}
map<ll,ll> getFactorization(ll x)
{
map<ll,ll> ret;
while (x != 1)
{
ret[spf[x]]++;
x = x / spf[x];
}
return ret;
}*/
void scanN(vector<ll>&v,ll n)
{
rep(i,0,n)
{
ll num;
cin>>num;
v.pub(num);
}
}
void scans(vector<string>& v,ll n)
{
rep(i,0,n)
{
string s;
cin>>s;
v.pub(s);
}
}

ll modfactorial(ll n,ll p)
{
if(n>=p)
return 0;
ll result = 1;
rep(i,1,n+1)
{
result = result*i;
result = result%p;
}
return result;
}
ll MI(ll a, ll b,ll s0 = 1,ll s1 = 0)
{
ll k = b;
if(b == 0)
return s0;
else
{
return MI(b,a%b,s1,s0-s1*(a/b));

}
}
ll choose(ll a,ll b,ll c = MOD)
{
if(a<b)
return 0;
ll x = modfactorial(a,c);
ll y = modfactorial(b,c);
ll z = modfactorial(a-b,c);
ll y_ = MI(y,c,1,0);
if(y_<0)
y_ = y_+c;
ll z_ = MI(z,c,1,0);
if(z_<0)
z_ = z_+c;
ll mul = (x*y_)%c;
mul = (mul*z_)%c;
return mul;
}
void SOLT()
{
int test;
cin>>test;
while(test--)
{
solve();
}
}
ll modpow(ll n,ll p,ll k)
{
n = n%k;
ll res = 1;
while(p>0)
{
if(p%2 == 1)
res = res*n%k;
n = n*n%k;
p = p/2;
}
return res;
}
ll __pow(ll n,ll p)
{
ll res = 1;
while(p>0)
{
if(p%2 == 1)
res = res*n;
n = n*n;
p = p/2;
}
return res;
}
ll str_mod_num(string b,ll c)
{
ll k = b.size();
vll mod(k+1);
mod[0] = 1;
//vll mod(k+1)
rep(i,1,k+1)
{
mod[i] = 10*mod[i-1];
mod[i]%=c;
}
ll rem = 0;
repr(i,k-1,-1)
{
ll num = b[i] - '0';
num*=mod[k-1-i];
num%=c;
rem+=num;
rem%=c;
}
return rem;
}
ll str_pow_str_mod_num(string b,string n,ll c)
{
ll tr = n.size();
ll rem = str_mod_num(b,c);
ll time_pass = n[0] - '0';
ll ans = modpow(rem,time_pass,c);
rep(i,1,tr)
{
time_pass = n[i] - '0';
ans = modpow(ans,10,c);
ans*=modpow(rem,time_pass,c);
ans%=c;
}
return ans;
}
bool isPrime(ll a) {
if(a == 1)
return 0;
for(ll i = 2; i * i <= a; ++i)
if(a % i == 0)
return false;
return true;
}

bool useflushdivisible(ll a) {
cout<<a<<endl;
fflush(stdout);
char sl[10];
scanf("%s", sl);
return sl[0] == 'y' || sl[0] == 'Y';
}
ll phi(ll n)
{
ll result = n;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
while (n % i == 0)
n =n/ i;
result =result - result / i;
}
}
if (n > 1)
result =result - result / n;
return result;
}
bool cmp(ll x,ll y)
{
return (x%2)<(y%2);

}
vll getfactors(ll n)
{
vll factors;
rep(i,1,(ll)sqrt(n)+1)
{
if(n%i == 0)
{
factors.pub(i);
if(i!=(n/i))
factors.pub(n/i);
}
}
return factors;
}
ll Binary_Search(vector<ll>& a,ll low,ll high,ll key)
{
if(high<low)
return a[low-1];
ll mid = low+(high-low)/2;
if(key == a[mid])
return a[mid];
else if(key<a[mid])
return Binary_Search(a,low,mid-1,key);
return Binary_Search(a,mid+1,high,key);
}
double area(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3)
{

return abs((x1*(y2-y3) + x2*(y3-y1)+ x3*(y1-y2))/2.0);
}

/* A function to check whether point P(x, y) lies inside the triangle formed

by A(x1, y1), B(x2, y2) and C(x3, y3) */

bool isInside(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3, int x, int y)
{

/* Calculate area of triangle ABC */

double A = area (x1, y1, x2, y2, x3, y3);

/* Calculate area of triangle PBC */

double A1 = area (x, y, x2, y2, x3, y3);

/* Calculate area of triangle PAC */

double A2 = area (x1, y1, x, y, x3, y3);

/* Calculate area of triangle PAB */

double A3 = area (x1, y1, x2, y2, x, y);

/* Check if sum of A1, A2 and A3 is same as A */

return (A == A1 + A2 + A3);
}
ll factorial(ll n)
{
if(n <= 1)
return 1;
else
return n*factorial(n-1);
}
int fun(vll arr, int n)
{
int x = arr[0];
for (int i = 1; i < n; i++)
x = x ^ arr[i];
return x;
}
ll tower_of_hanoi_number_of_ways(ll n,ll a = 3)
{
if(n == 1)
return 1;
else
{
ll p = tower_of_hanoi_number_of_ways(n-1,1);
ll q = tower_of_hanoi_number_of_ways(n-1,2);
return p+q+1;
}
}
void tower_of_hanoi_details(ll n,char a = '1',char b = '2',char c = '3')
{
if(n == 1)
{
cout<<a<<" "<<c<<endl;
return;
}
tower_of_hanoi_details(n-1,a,c,b);
cout<<a<<" "<<c<<endl;
tower_of_hanoi_details(n-1,b,a,c);
}
bool partition (vll arr)
{
ll n = arr.size();
int sum = 0;
int i, j;

for (i = 0; i < n; i++)
sum += arr[i];

if (sum % 2 != 0)
return false;

bool part[n + 1][sum / 2 + 1];

// initialize top row as false
for (i = 0; i <= sum/2; i++)
part[0][i] = false;

// initialize leftmost column as true
for (i = 0; i <= n; i++)
part[i][0] = true;

// Fill the partition table in botton up manner
for (i = 1; i <= n; i++)
{
for (j = 1; j <= sum/2; j++)
{
part[i][j] = part[i-1][j];
if (j >= arr[i - 1])
part[i][j] = part[i][j] ||
part[i - 1][j - arr[i -1]];

}
}

return part[n][sum/2];
}
ll myceil(ll a,ll b)
{
ll k = a/b;
if(a%b)
k++;
return k;
}
int32_t main()
{

FAST();
int test = 1;
//srand(time(0));
cin>>test;
for(int tt = 1;tt<=test;tt++)
{
//cout<<"Case #"<<tt<<": ";
solve();
}
return 0;
}
void solve()
{
ll r,b,d;
cin>>r>>b>>d;
ll ma = max(r,b);
ll mi = min(r,b);
if(ma<=mi+d)
{
cy;
return;
}
if(ma<=mi*(d+1))
{
cy;
return;
}
cn;
}

ll Rselect(vector<ll> v, ll i, ll l, ll r)
{
if (l == r)
return v[l];
ll pivot = partition(v, l, r);
if (pivot == i)
return v[pivot - 1];
else if (pivot < i)
{
return Rselect(v, i, pivot, r);
}
else
{
return Rselect(v, i, l, pivot - 2);
}
}

ll partition(vector<ll> v, ll l, ll r)
{
ll pivot_index = rand() % (r - l + 1) + l;
swap(v[pivot_index], v[l]);
ll i = l + 1, j = l + 1;
while (j <= r)
{
if (v[j] < v[l])
{
swap(v[j], v[i]);
i++;
}
j++;
}
swap(v[l], v[i - 1]);
return i;
}

## JAVA

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main implements Runnable {
int n, m, k;
static boolean use_n_tests = true;
int mod = 1000_000_007;
int[][] res;

void solve(FastScanner in, PrintWriter out, int testNumber) {
int r, b, d;
r = in.nextInt();
b = in.nextInt();
d = in.nextInt();
int mn = Math.min(r, b);
int mx = Math.max(r, b);
out.println((mx + mn - 1) / mn - 1 <= d ? "YES" : "NO");
}

// ****************************** template code ***********
long binpow(long a, int b) {
long res = 1;
while (b != 0) {
if (b % 2 == 0) {
b /= 2;
a *= a;
a %= mod;
}

b--;
res *= a;
res %= mod;
}
return res;
}

List<Integer> getGidits(long n) {
List<Integer> res = new ArrayList<>();
while (n != 0) {
n /= 10;
}
return res;
}

List<Integer> generatePrimes(int n) {
List<Integer> res = new ArrayList<>();
boolean[] sieve = new boolean[n + 1];
for (int i = 2; i <= n; i++) {
if (!sieve[i]) {
}
if ((long) i * i <= n) {
for (int j = i * i; j <= n; j += i) {
sieve[j] = true;
}
}
}
return res;
}

int ask(int l, int r) {
if (l >= r) {
return -1;
}
System.out.printf("? %d %d\n", l + 1, r + 1);
System.out.flush();
return in.nextInt() - 1;
}

static int stack_size = 1 << 27;

class Mod {
long mod;

Mod(long mod) {
this.mod = mod;
}

long add(long a, long b) {
a = mod(a);
b = mod(b);
return (a + b) % mod;
}

long sub(long a, long b) {
a = mod(a);
b = mod(b);
return (a - b + mod) % mod;
}

long mul(long a, long b) {
a = mod(a);
b = mod(b);
return a * b % mod;
}

long div(long a, long b) {
a = mod(a);
b = mod(b);
return (a * inv(b)) % mod;
}

public long inv(long r) {
if (r == 1)
return 1;
return ((mod - mod / r) * inv(mod % r)) % mod;
}

private long mod(long a) {
return a % mod;
}
}

static class Coeff {
long mod;
long[][] C;
long[] fact;
boolean cycleWay = false;

Coeff(int n, long mod) {
this.mod = mod;
fact = new long[n + 1];
fact[0] = 1;
for (int i = 1; i <= n; i++) {
fact[i] = i;
fact[i] %= mod;
fact[i] *= fact[i - 1];
fact[i] %= mod;
}
}

Coeff(int n, int m, long mod) {
// n > m
cycleWay = true;
this.mod = mod;
C = new long[n + 1][m + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= Math.min(i, m); j++) {
if (j == 0 || j == i) {
C[i][j] = 1;
} else {
C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
C[i][j] %= mod;
}
}
}
}

public long C(int n, int m) {
if (cycleWay) {
return C[n][m];
}
return fC(n, m);
}

private long fC(int n, int m) {
return (fact[n] * inv(fact[n - m] * fact[m] % mod)) % mod;
}

private long inv(long r) {
if (r == 1)
return 1;
return ((mod - mod / r) * inv(mod % r)) % mod;
}
}

class Pair {
int first;
long second;

Pair(int f, long s) {
first = f;
second = s;
}

public int getFirst() {
return first;
}

public long getSecond() {
return second;
}
}

class MultisetTree<T> {
int size = 0;

TreeMap<T, Integer> mp = new TreeMap<>();

mp.merge(x, 1, Integer::sum);
size++;
}

void remove(T x) {
if (mp.containsKey(x)) {
mp.merge(x, -1, Integer::sum);
if (mp.get(x) == 0) {
mp.remove(x);
}
size--;
}
}

boolean contains(T x) {
return mp.containsKey(x);
}

T greatest() {
return mp.lastKey();
}

T smallest() {
return mp.firstKey();
}

int size() {
return size;
}

int diffSize() {
return mp.size();
}
}

class Multiset<T> {
int size = 0;

Map<T, Integer> mp = new HashMap<>();

mp.merge(x, 1, Integer::sum);
size++;
}

boolean contains(T x) {
return mp.containsKey(x);
}

void remove(T x) {
if (mp.containsKey(x)) {
mp.merge(x, -1, Integer::sum);
if (mp.get(x) == 0) {
mp.remove(x);
}
size--;
}
}

int size() {
return size;
}

int diffSize() {
return mp.size();
}
}

static class Range {
int l, r;
int id;

public int getL() {
return l;
}

public int getR() {
return r;
}

public Range(int l, int r, int id) {
this.l = l;
this.r = r;
this.id = id;
}
}

static class Array {
static Range[] readRanges(int n, FastScanner in) {
Range[] result = new Range[n];
for (int i = 0; i < n; i++) {
result[i] = new Range(in.nextInt(), in.nextInt(), i);
}
return result;
}

static List<List<Integer>> intInit2D(int n) {
List<List<Integer>> res = new ArrayList<>();
for (int i = 0; i < n; i++) {
}
return res;
}

static boolean isSorted(Integer[] a) {
for (int i = 0; i < a.length - 1; i++) {
if (a[i] > a[i + 1]) {
return false;
}
}
return true;
}

static public long sum(int[] a) {
long sum = 0;
for (int x : a) {
sum += x;
}
return sum;
}

static public long sum(long[] a) {
long sum = 0;
for (long x : a) {
sum += x;
}
return sum;
}

static public long sum(Integer[] a) {
long sum = 0;
for (int x : a) {
sum += x;
}
return sum;
}

static public int min(Integer[] a) {
int mn = Integer.MAX_VALUE;
for (int x : a) {
mn = Math.min(mn, x);
}
return mn;
}

static public int min(int[] a) {
int mn = Integer.MAX_VALUE;
for (int x : a) {
mn = Math.min(mn, x);
}
return mn;
}

static public int max(Integer[] a) {
int mx = Integer.MIN_VALUE;
for (int x : a) {
mx = Math.max(mx, x);
}
return mx;
}

static public int max(int[] a) {
int mx = Integer.MIN_VALUE;
for (int x : a) {
mx = Math.max(mx, x);
}
return mx;
}

static public int[] readint(int n, FastScanner in) {
int[] out = new int[n];
for (int i = 0; i < out.length; i++) {
out[i] = in.nextInt();
}
return out;
}
}

class Graph {
List<List<Integer>> graph;

Graph(int n) {
create(n);
}

private void create(int n) {
List<List<Integer>> graph = new ArrayList<>();
for (int i = 0; i < n; i++) {
}
this.graph = graph;
}

void readBi(int m, FastScanner in) {
for (int i = 0; i < m; i++) {
int v = in.nextInt() - 1;
int u = in.nextInt() - 1;
}
}
}

class FastScanner {
StringTokenizer st;

public FastScanner(InputStream io) {
}

public String line() {
String result = "";
try {
} catch (IOException e) {
e.printStackTrace();
}
return result;
}

public String next() {
while (st == null || !st.hasMoreElements()) {
try {
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}

public char[] nextc() {
return next().toCharArray();
}

public int nextInt() {
return Integer.parseInt(next());
}

public int[] nextArray(int n) {
int[] res = new int[n];
for (int i = 0; i < n; i++) {
res[i] = in.nextInt();
}
return res;
}

public long[] nextArrayL(int n) {
long[] res = new long[n];
for (int i = 0; i < n; i++) {
res[i] = in.nextLong();
}
return res;
}

public Long[] nextArrayL2(int n) {
Long[] res = new Long[n];
for (int i = 0; i < n; i++) {
res[i] = in.nextLong();
}
return res;
}

public Integer[] nextArray2(int n) {
Integer[] res = new Integer[n];
for (int i = 0; i < n; i++) {
res[i] = in.nextInt();
}
return res;
}

public long nextLong() {
return Long.parseLong(next());
}

}

void run_t_tests() {
int t = in.nextInt();
int i = 0;
while (t-- > 0) {
solve(in, out, i++);
}
}

void run_one() {
solve(in, out, -1);
}

@Override
public void run() {
in = new FastScanner(System.in);
out = new PrintWriter(System.out);
if (use_n_tests) {
run_t_tests();
} else {
run_one();
}
out.close();
}

static FastScanner in;
static PrintWriter out;

public static void main(String[] args) throws InterruptedException {
}